<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBExperience 3.8                                                 # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2006-2009 Marius Czyz. All Rights Reserved.           # ||
|| #################################################################### ||
\*======================================================================*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('cpuser', 'forum', 'user', 'cpglobal');
$specialtemplates = array();

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_xperience.php');
require_once(DIR . '/includes/adminfunctions_plugin.php');
// ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminusers'))
{
	print_cp_no_permission();
}
 
// ############################# LOG ACTION ###############################
log_admin_action();

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

print_cp_header("Remove vBExperience");


$vbulletin->input->clean_array_gpc('r', array('do' => TYPE_STR));


if ($vbulletin->GPC['do'] == 'kill') 
{
	print_form_header('');
	print_table_header("Remove vBExperience", 1);

	delete_product("iwt_vbexp_ibparcade");
	delete_product("iwt_vbexp_v3arcade");
	delete_product("xpphotoplog");
	delete_product("abe1_post_thanks_experien");
	delete_product("xppostrate");
	delete_product("xpquotes");
	delete_product("xpscrupulous");
	delete_product("xpnecro");
	delete_product("xpdeladdict");
	
	delete_product("xp_upom");
	delete_product("vbexperience3");
	delete_product("xperience38");


	
	$vbulletin->db->hide_errors();
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_level");
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_shop");
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_shop_ta");
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_shop_cat");
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_awards");
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_groups");	
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_custompoints");
	$vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "xperience_promotion_log");
	$vbulletin->db->show_errors();

	DoDropColumns();
	
	print_description_row("vBExperience has been removed from database. You must now delete files on your server.");
	print_description_row("<b>PLEASE UNINSTALL THE PRODUCT XML MANUALLY FROM THE PLUGINSYSTEM.</b>");
	print_description_row("<b>ESPACIALLY IF YOU GET SQL ERRORS LIKE <i>Unknown column 'xperience_done' in 'field list'.</i></b>");
	print_table_footer(1);

} else {
	print_form_header('');
	print_table_header("Confirm remove of vBExperience", 1);
	print_description_row('This will remove ALL tables, incl. Custom Points, Shop, Cats/Items, Transactions... You will have to remove product XML for yourself.');
	print_description_row('<a href="kill_xperience.php?do=kill">Do it</a>');
	print_table_footer(1);

}


print_cp_footer();


?>
