2005-01-22 22:05:34 -05:00
|
|
|
<?php
|
|
|
|
@define('NWNADMIN_BASE', dirname(__FILE__));
|
|
|
|
|
|
|
|
require_once NWNADMIN_BASE . '/lib/base.php';
|
|
|
|
|
|
|
|
// script global variables
|
|
|
|
global $nwndriver;
|
|
|
|
$params = &$nwndriver->getParams();
|
|
|
|
$configured = false;
|
|
|
|
$rawResult = false;
|
|
|
|
$wait = false;
|
|
|
|
|
|
|
|
// no regular users allowed on this page
|
|
|
|
if (!Auth::isAdmin('nwnadmin:admin')) {
|
2005-01-23 00:41:56 -05:00
|
|
|
header('Location: ./server.php');
|
2005-01-22 22:05:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// hack the page if the server is not configured
|
|
|
|
if (!$params || is_a($params, 'PEAR_Error') ||
|
|
|
|
!isset($params['servername']) || $params['servername'] == '') {
|
|
|
|
$notification->push(_("The server is not configured!"), 'horde.warning');
|
|
|
|
} else {
|
|
|
|
$configured = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$actionId = Util::getFormData('actionId');
|
|
|
|
switch ($actionId) {
|
|
|
|
case 'stop':
|
|
|
|
$wait = true;
|
|
|
|
$result = $nwndriver->stopServer();
|
|
|
|
if (is_a($result, 'PEAR_Error')) {
|
|
|
|
$notification->push(_("There was a problem stopping the server: ") .
|
|
|
|
$result->getMessage(), 'horde.error');
|
|
|
|
} else {
|
2005-01-23 02:23:18 -05:00
|
|
|
$notification->push(
|
|
|
|
_("The server was stopped. Reload if still running."),
|
|
|
|
'horde.success');
|
2005-01-22 22:05:34 -05:00
|
|
|
}
|
2005-01-23 01:39:20 -05:00
|
|
|
break;
|
2005-01-22 22:05:34 -05:00
|
|
|
case 'start':
|
|
|
|
$wait = true;
|
|
|
|
$result = $nwndriver->startServer();
|
|
|
|
if (is_a($result, 'PEAR_Error')) {
|
|
|
|
$notification->push(_("There was a problem starting the server: ") .
|
|
|
|
$result->getMessage(), 'horde.error');
|
|
|
|
} else {
|
|
|
|
$notification->push(_("The server was started."), 'horde.success');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'kill':
|
|
|
|
$wait = true;
|
|
|
|
$result = $nwndriver->killServer();
|
|
|
|
if (is_a($result, 'PEAR_Error')) {
|
|
|
|
$notification->push(_("There was a problem killing the server: ") .
|
|
|
|
$result->getMessage(), 'horde.error');
|
|
|
|
} else {
|
|
|
|
$notification->push(_("The server was killed."), 'horde.warning');
|
|
|
|
}
|
|
|
|
case 'raw':
|
2005-01-23 01:17:36 -05:00
|
|
|
$wait = true;
|
2005-01-22 22:05:34 -05:00
|
|
|
$result = $nwndriver->sendCommand(Util::getFormData('command'), true);
|
|
|
|
if (is_a($result, 'PEAR_Error')) {
|
|
|
|
$notification->push(_("There was a problem sending the command: ") .
|
|
|
|
$result->getMessage(), 'horde.error');
|
|
|
|
} else {
|
|
|
|
$rawResult = $result;
|
|
|
|
$notification->push(_("The command was accepted."), 'horde.success');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// select form to display
|
|
|
|
if ($wait) { sleep(2); }
|
|
|
|
if ($nwndriver->serverRunning()) {
|
|
|
|
$title = _("Stop/Restart/Kill Server");
|
|
|
|
$form = 'kill.inc';
|
|
|
|
} else {
|
|
|
|
$title = _("Run Server");
|
|
|
|
$form = 'start.inc';
|
|
|
|
}
|
|
|
|
|
|
|
|
// start the page
|
|
|
|
require_once NWNADMIN_TEMPLATES . '/common-header.inc';
|
|
|
|
require_once NWNADMIN_TEMPLATES . '/menu.inc';
|
|
|
|
|
|
|
|
// this is cheap, but the redirect/notification combination doesn't work right
|
|
|
|
if ($configured) {
|
|
|
|
// output the form
|
|
|
|
include NWNADMIN_TEMPLATES . '/start/' . $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($rawResult) {
|
|
|
|
printf("<br /><div class='header'>Command Result</div><br />" .
|
|
|
|
"<div class='fixed'>%s</div>", nl2br($nwndriver->getLogContent()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// finish up the page
|
2005-01-23 00:41:56 -05:00
|
|
|
require_once $registry->get('templates', 'horde') . '/common-footer.inc';
|