<?php
header("Content-type:text/html;charset=utf-8");  
session_start();
$session_admin = isset($_SESSION['admin']) ? $_SESSION['admin'] : ''; 
if ($session_admin == '') {
	die("Can not access");
}
require_once("../common.php");
checkadminrights($session_admin, 'publicwebapps');

function step2() {
	require_once("../common.php");

	$appid = isset($_GET['appid']) ? $_GET['appid'] : '0';
	$appname = isset($_GET['appname']) ? urldecode($_GET['appname']) : '';

	$methodname = 'Admin.RemoveWebApp';
	$requestinfo = '<?xml version="1.0" encoding="utf-8"?><request>' . 
		'<ip>' . getip() . '</ip>' . 
		'<appid>' . $appid . '</appid>' . 
		'</request> ';
	$responseinfo = '';
	$responsexml = null;
	$errorcode = ERRORCODE_UNKNOWN;

	$cmd = new COM("OpenCom.Command");
	$methodname = iconv('UTF-8', 'GBK//IGNORE', $methodname);
	$requestinfo = iconv('UTF-8', 'GBK//IGNORE', $requestinfo);
	if ($cmd->Execute($methodname, $requestinfo, $responseinfo, 5000)) {
		$responseinfo = iconv('GBK', 'UTF-8//IGNORE', $responseinfo);
		$responsexml = simplexml_load_string($responseinfo);
		$errorcode = $responsexml->errorcode;
	}
	$cmd = null;

	switch($errorcode) {
		case ERRORCODE_OK: 
			header("Location: publicwebapps.php");
			break;
		default:
			header("Location: publicwebapps.php");
	}//switch
}//step2

$step = isset($_GET['step']) ? $_GET['step'] : '1'; 

if ($step == '2') {
	step2();
	exit;
}
?>
<!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>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="../css/base.css" />
</head>
<body>

<?php
	$appid = isset($_GET['appid']) ? $_GET['appid'] : '0';
	$appname = isset($_GET['appname']) ? urldecode($_GET['appname']) : '';

	//subpageurlparams
	$subpageurlparams = 'appid=' . $appid . '&appname=' . urlencode($appname);

echo<<<EOT
	<div class="msgbox">
		<div class="msgbox_text">
			<img width="40px" height="40px" align="absmiddle" src="../images/warning.gif" />&nbsp;确定删除应用&nbsp;&quot;$appname&quot;？
		</div>
		<div class="msgbox_btns">
			<input class="cssbtn" type="button" value="确定" onclick="window.location='publicwebapps_remove.php?step=2&{$subpageurlparams}'" />
			<input class="cssbtn" type="button" value="取消" onclick="window.location='publicwebapps.php'" />
		</div>
	</div>
EOT;
?>

</body>
</html>
