<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created:	11/28/2013	ELL
// Modified: 9/5/2014	ELL
// Added Generate Site Map button.
// Revised: 4/12/2016	ELL
// Added ids to buttons to provide click control from main menu.
// Revised: 5/27/2016	ELL
// Added lockout of Clear All Custom CSS.
// Revised: 5/1/2017	ELL
// Added button for restricting blogging pages to bloggers.
// Revised: 6/19/2017	ELL
// Moved 'deployed' field to new table plugins_deployed.
// 

	include ("check_session.php");
	
	if ($access_level != "admin")
		exit;
	
	$display_pruned_bkup_files_msg = $_REQUEST['display_pruned_bkup_files_msg'];
	
	$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "options_selected` WHERE `option_name` = 'LockoutClearAllCustomCSSClasses'";
	$result = $bwb_dbh->query($query);
	$row = $result->fetch(PDO::FETCH_ASSOC);
	$LockoutClearAllCustomCSSClasses = $row['option_value'];
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin Function Select | Breeze Website Builder</title>
<link rel="stylesheet" href="theme/<?php echo $theme; ?>/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;
}
#btn_prune_css	{	
	width:258px;
	height:60px;
	border-top:none;
}
#btn_prune_table	{	
	width:180px;
	display:block;
	position:relative;
	left:40px;
}
#btn_recall_plugin	{	
	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 = '" . ADMIN_FUNCTION_SELECT_DEACTIVATE_SITE_CONFIRM_MSG . "';\n";
		echo "	var activate = 0;\n";
	}
	else
	{
		echo "	var msg = '" . ADMIN_FUNCTION_SELECT_ACTIVATE_SITE_CONFIRM_MSG . "';\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"><?php echo ADMIN_FUNCTION_SELECT_HEADING; ?></div><div class="help_button" id="help_button" onClick="OpenHelpWindow();">&nbsp;</div></div>
    
	<div class='button_sub_level_1' id='btn_users' onClick="window.location='users.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_MANAGE_USERS_BTN; ?></span></div>
    <div class='button_sub_level_1' id='btn_site_options' onClick="window.location='options.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_CHANGE_SITE_OPTIONS_BTN; ?></span></div>
    <div class='button_sub_level_1' id='btn_restrict_editing_access' onClick="window.location='restrict_editing_access.php?AccessLevel=restricted';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_RESTRICT_PAGE_EDITING_ACCESS_BTN; ?></span></div>
    <div class='button_sub_level_1' id='btn_restrict_editing_access' onClick="window.location='restrict_editing_access.php?AccessLevel=blogger';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_RESTRICT_BLOG_PAGE_EDITING_ACCESS_BTN; ?></span></div>
    <div class='button_sub_level_1' id='btn_generate_site_map' onClick="window.location='generate_site_map_shell.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_GENERATE_SITE_MAP_BTN; ?></span></div>
    <div class='button_sub_level_1' id='btn_prune_page_edit_bkup_tbl' onClick="ShowPrunePageEditBkupTable();"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_PRUNE_PAGE_EDIT_BACKUP_TABLE_BTN; ?></span></div>
	<div class='button_console' id="btn_prune_css" onClick="window.location='prune_bkup_files.php';"><span class='button_console_text'><?php echo ADMIN_FUNCTION_SELECT_PRUNE_BACKUP_FILES_BTN; ?></span></div>
<?php if ($LockoutClearAllCustomCSSClasses != 1)	{	?>
    <div class='button_sub_level_1' id='btn_delete_custom_classes' onClick="window.location='delete_custom_classes_select.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_CLEAR_CUSTOM_CLASSES_BTN; ?></span></div>
<?php }	?>
	<div class='button_sub_level_1' id='btn_upload_plugin' onClick="window.location='upload_plugin.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_INSTALL_PLUGIN_BTN; ?></span></div>
	<div class='button_sub_level_1' id='btn_show_recall_plugin' onClick="ShowRecallPlugin();"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_RECALL_PLUGIN_BTN; ?></span></div>
	<div class='button_sub_level_1' id='btn_upload_update' onClick="window.location='upload_update.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_INSTALL_UPDATE_BTN; ?></span></div>
    <div class='button_sub_level_1' id='btn_input_sql' onClick="window.location='input_sql.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_RUN_SQL_BTN; ?></span></div>
    <div class='button_sub_level_1' id='btn_backup_restore' onClick="window.location='backup_restore.php';"><span class='button_text_sub_level_1'><?php echo BACKUP_RESTORE_HEADING; ?></span></div>
    <div class='button_sub_level_1' id='btn_server_info' onClick="window.location='server_info.php';"><span class='button_text_sub_level_1'><?php echo ADMIN_FUNCTION_SELECT_SHOW_SERVER_INFO_BTN; ?></span></div>
	<div class='button_sub_level_1' id='btn_activate_deactivate_site' onClick="ActivateDeactivateConfirm();"><span class='button_text_sub_level_1'><?php if ($site_active) echo ADMIN_FUNCTION_SELECT_DEACTIVATE_WEBSITE_BTN; else  echo ADMIN_FUNCTION_SELECT_ACTIVATE_WEBSITE_BTN; ?></span></div>
</div>

<div id="prune_page_backup_table_div">
<form name="frmPruneTable" id="frmPruneTable" method="post" action="prune_table.php">
	<p><?php echo ADMIN_FUNCTION_SELECT_PRUNE_PAGE_EDIT_BACKUP_TABLE_TO; ?> 
	    <input name="prune_page_bkup_days" type="text" id="prune_page_bkup_days" value="30" size="4" />
	<?php echo DAYS_WORD; ?><br>
      <div class='button_console' id="btn_prune_table" onClick="document.getElementById('frmPruneTable').submit();"><span class='button_console_text'><?php echo SUBMIT_WORD; ?></span></div>
	</p>
</form>
</div>

<div id="recall_plugin_div">
  <?php echo ADMIN_FUNCTION_SELECT_SELECT_PLUGIN_TO_RECALL; ?>:<br />
  	<select name="recall_plugin" id="recall_plugin" style="width:400px;">
<?php
	$query = "SELECT T1.id, T1.name, T1.description FROM " . BWB_TABLE_PREFIX . "plugins AS T1 INNER JOIN " . BWB_TABLE_PREFIX . "plugins_deployed AS T2 ON T1.id = T2.plugin_id WHERE T2.deployed=1 ORDER BY T1.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="btn_recall_plugin" 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 = "<?php echo ADMIN_FUNCTION_SELECT_BACKUP_FILES_HAVE_BEEN_PRUNED_MSG; ?>";
	popup_msg.ShowPopupMsg();
<?php	}	?>
</script>

</body>
</html>