<?php
/*********************************************************************/
/* MineCobalt - Minecraft SMP Web Administration */
/* Copyright (c) 2011, Mark Randall @ MineCobalt */
/* All rights reserved. */
/*********************************************************************/
/* Please read licence.txt */
/*********************************************************************/
/* Pagename: ajaxcall.php */
/* Purpose: This page handles the AJAXll from the pages */
/*********************************************************************/
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
require(".settings/siteconfig.php");
require(".classes/mysql.php");
$sql = new mysql_connection($config['mysql']['username'], $config['mysql']['password'], $config['mysql']['hostname'], $config['mysql']['port'], $config['mysql']['database']);
require(".classes/bukkit.php");
$bukkit = new bukkit($config['minecraft']['server'],$config['minecraft']['port']);
$bukkit->connect();
//
// Load the action that we want from the post string
//
$action = $_REQUEST['action'];
$action = strtolower($action);
switch($action){
case "give":
$bukkit->give($_POST['playername'],$_POST['itemid'],$_POST['qunatity']);
echo "Successfully given {$_POST['qunatity']}x{$_POST['itemid']} to {$_POST['playername']}";
break;
case "getplayers":
$players = $bukkit->playerlist();
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo '<players>';
foreach($players[0] as $key => $value){
echo "<name>".$value."</name>";
}
echo '</players>';
break;
case "listinventory":
$players = $bukkit->invlist($_REQUEST['playername']);
echo '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
echo '<players>'."\n";
foreach($players['inventory_items']['slots'] as $key => $value){
echo "<slot>\n";
echo "\t<number>".$value['num']."</number>\n";
echo "\t<type>".$value['type']."</type>\n";
echo "\t<quantity>".$value['amount']."</quantity>\n";
echo "</slot>\n";
}
echo '</players>'."\n";
break;
default:
echo "no action specified";
}
$bukkit->close();
?>