<?php
require("session_check.php");
$pl_langpackage=new pluginslp;
$plugin_dir=dir(dirname(__file__)."/../plugins");
chdir(dirname(__file__)."/../plugins");
function getInfo($path)
{
	global $pl_langpackage;
	global $dir;
	$p_status=$pl_langpackage->pl_unset;
	$p_change=$pl_langpackage->pl_install;
	$p_update="Update(\"update_plugin.php?path=$path\")";
	$p_operator="Install";
	$p_index="install_plugin_1.php";
	$pluginxml=dirname(__file__)."/../plugins/$path/plugin.xml";
	if(file_exists($pluginxml))
	{
		$p_update="noinstall()";
	}
	else
	{
		$pluginxml=dirname(__file__)."/../plugins/$path/_plugin.xml";
		$p_status=$pl_langpackage->pl_isset;
		$p_change=$pl_langpackage->pl_unload;
		$p_index="unload_plugin.php";
		$p_operator="Unloadfirm";
	}
	if(file_exists($pluginxml))
	{
		$dom = new DOMDocument();
		$dom->load($pluginxml);
		$plugin=$dom->getElementsByTagName("plugin");
		$infos=$plugin->item(0)->childNodes;
		$plugin_id="";
		$auto_checked="";
		$valid_checked="";
		foreach($infos as $info)
		{
			if($info->nodeName!="#text")
			{
				$tem=$info->nodeName;
				$$tem=$info->nodeValue;
			}
		}
		if($autoorder)$auto_checked="checked='checked'";
		if($valid)$valid_checked="checked='checked'";
		echo "<tr><td><a href='#' onclick='$p_update'>$title</a></td><span id='span_$path'></span></td><td>$p_status</td><td><input class='top_button' type='submit' onclick=\"$p_operator('$p_index?path=$path')\" value='$p_change'/></td></tr>";
	}
}
?>
<!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" />
<link rel="stylesheet" type="text/css" href="css/right.css">
<script type="text/javascript" src="js/plugin.js"></script>
<script type='text/javascript'>
var diag_install = new parent.Dialog("Diag1","<?php echo $pl_langpackage->pl_next_step;?>");
var install_submit="";
var install_end=false;
var unload_end=false;
var url="";
function Install(url){
	diag_install.Width = 600;
	diag_install.Height = 350;
	diag_install.Title = "<?php echo $pl_langpackage->pl_guide;?>";
	diag_install.URL = url;
	diag_install.ShowMessageRow = true;
	diag_install.MessageTitle = "<?php echo $pl_langpackage->pl_install_info;?>";
	diag_install.Message = "<?php echo $pl_langpackage->pl_install_worning;?>";
	diag_install.OKEvent = installNext;//点击确定后调用的方法
	diag_install.show();
}
function installNext()
{
	if(install_submit!="")
	{
		diag_install.Ok="<?php echo $pl_langpackage->pl_sure;?>";
		parent.window.frames["_DialogFrame_Diag1"].document.setplugin.submit();
		install_submit="";
	}else
	{
		diag_install.show(); 
	}
	if(install_end)
	{
		diag_install.close();
		next();
	}
}
var diag_unload = new parent.Dialog("Diag2","<?php echo $pl_langpackage->pl_sure;?>");
function Unload(url){
	diag_unload.Width = 600;
	diag_unload.Height = 350;
	diag_unload.Title = "<?php echo $pl_langpackage->pl_guide;?>";
	diag_unload.URL = url;
	diag_unload.Ok="<?php echo $pl_langpackage->pl_sure;?>";
	diag_unload.ShowMessageRow = true;
	diag_unload.MessageTitle = "<?php echo $pl_langpackage->pl_unload_info;?>";
	diag_unload.Message = "<?php echo $pl_langpackage->pl_unload_remind;?>";
	diag_unload.OKEvent = unloadNext;//点击确定后调用的方法
	diag_unload.show();
}
function unloadNext()
{
	diag_unload.close();
	next();
}
var diag_update = new parent.Dialog("Diag3","<?php echo $pl_langpackage->pl_update;?>");
function Update(url){
	diag_update.Width = 600;
	diag_update.Height = 300;
	diag_update.Title = "<?php echo $pl_langpackage->pl_manage_str;?>";
	diag_update.URL=url;
	diag_update.ShowMessageRow = true;
	diag_update.MessageTitle = "<?php echo $pl_langpackage->pl_manage;?>";
	diag_update.Message = "<?php echo $pl_langpackage->pl_set_update;?>";
	diag_update.OKEvent = updateform;
	diag_update.show();
}
function updateform()
{
   parent.window.frames["_DialogFrame_Diag3"].document.uploadform.submit();
}
function next()
{
	location.replace('pluginlist.php');
}
function Unloadfirm(url){
	parent.Dialog.confirm('<?php echo $pl_langpackage->pl_worning;?>',function(){Unload(url);},"<?php echo $pl_langpackage->pl_sure;?>");
}
function noinstall()
{
	parent.Dialog.alert('<?php echo $pl_langpackage->pl_unset_state;?>',"<?php echo $pl_langpackage->pl_sure;?>");
}
</script>
<title></title>
</head>
<body>
<div class="container">
	<div class="rs_head"><?php echo $pl_langpackage->pl_list;?></div>
</div>
	<table class="main">
		<tr><th><?php echo $pl_langpackage->pl_name;?></th><th><?php echo $pl_langpackage->pl_state;?></td><th><?php echo $pl_langpackage->pl_ctrl;?></th></tr>
		<?php
		while (false !== ($dir = $plugin_dir->read())) {
			if(is_dir($dir)&&$dir!='.' &&$dir!='..')getInfo($dir);
		}
		$plugin_dir->close();
		?>
	</table>
</body>
</html>