<?php
require("session_check.php");
$pl_langpackage=new pluginslp;
$plugin_table=$tablePreStr."plugins";
$plugin_base=dirname(__file__)."/../plugins";
$path=get_args('path');
?>
	<!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></title>
</head>
<body style="text-align:center">
	<div style="width:100%" >
<?php
if(!is_null($path))
{
	//检测是不是有数据库文件
	$create_tables="$plugin_base/$path/plugin_create_tables.php";
	$dbo = new dbex;
	dbtarget('w',$dbServs);
	if(file_exists($create_tables))
	{
		$tables=explode(';',file_get_contents($create_tables));
		foreach($tables as $table)
		{
			$sql="drop table ".$table;
			if($dbo->exeUpdate($sql)) echo "<div style='color:green'>表:{$table}已成功删除<br /></div>";
		}
		unlink($create_tables);
	}
	if(rename("$plugin_base/$path/_plugin.xml","$plugin_base/$path/plugin.xml"))
	{
		$dom = new DOMDocument();
		$dom->load("$plugin_base/$path/plugin.xml");
		$plugin=$dom->getElementsByTagName("plugin")->item(0);
		$plugin_id=$plugin->getElementsByTagName("plugin_id")->item(0);
		$autoorder=$plugin->getElementsByTagName('autoorder')->item(0);
		$valid=$plugin->getElementsByTagName('valid')->item(0);
		if($plugin_id)$plugin->removeChild($plugin_id);
		if($autoorder)$plugin->removeChild($autoorder);
		if($valid)$plugin->removeChild($valid);
		$dom->formatOutput=true;
		$dom->save("$plugin_base/plugin.xml");
		$sql="delete from $plugin_table where name='$path'";
		if($dbo->exeUpdate($sql))echo "<div style='color:green'>此插件卸载成功!</div>";
	}
}
?>
</div>
</body>
</html>
