<?php

$accessControl = array('Admin' => true); 
require_once '../../AccessControl.php';

if (isset($_REQUEST["uninstall"]) && $_REQUEST["uninstall"] == "confirm") {
    // if(getGlobalSetting("IsWordPressInstall") == true) {
    // 	if(!empty($mysqlprefix)) {
    // 		 if ($q = $db->Execute("SHOW TABLES FROM ". $DatabaseName ." LIKE ". $db->Quote("{$mysqlprefix}%"))) {
    // 			while($tbl = $q->FetchRow()) {
    // 				$db->Execute("DROP TABLE ". $tbl[0]);
    // 			}

    // 			$active_plugins = $db->Execute("SELECT * FROM wp_options WHERE option_name = 'active_plugins'");
    // 			$plugindata = $active_plugins->FetchRow();

    // 			$plugins = unserialize($plugindata['option_value']);

    // 			foreach($plugins as $pluginid => $plugin) {
    // 				if(strpos($plugin, "logaholic") !== false) {
    // 					unset($plugins[$pluginid]);
    // 				}
    // 			}

    // 			$plugindata['option_value'] = serialize($plugins);
    // 			$active_plugins = $db->Execute("UPDATE wp_options SET option_value = ". $db->Quote($plugindata['option_value']) ."  WHERE option_name = 'active_plugins'");

    // 			$wp_url = $db->Execute("SELECT * FROM wp_options WHERE option_name = 'siteurl'");
    // 			$wp_url = $wp_url->FetchRow();
    // 			$wp_url = $wp_url['option_value'];
    // 			header("Location: {$wp_url}");
    // 		}
    // 	}
    // 	session_destroy();
    // 	exit;
	// }
	
	if ($db->Execute("drop database ". $DatabaseName)) {
		$res = array("Status" => "Success", "Message" => _DATABASE." ". $DatabaseName ." "._REMOVED);
	}  else {
		$res = array("Status" => "Error", "Message" => _PROBLEM_DELETING_DATABASE . $DatabaseName);
	}
	
	$res['Data'] = _WHAT_TO_DO_TO_UNINSTALL;
	echo json_encode($res);
    session_destroy();
}