From db4b7919db391fe31832f4560d690d64eed8fae2 Mon Sep 17 00:00:00 2001 From: penguinc Date: Sun, 23 Jan 2005 06:39:20 +0000 Subject: [PATCH] Better module error handling and removed the 'restart' function of the start page. --- lib/NWNDriver.php | 24 +++++++++++++++++++++--- module.php | 2 +- start.php | 3 +-- templates/start/kill.inc | 12 +----------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lib/NWNDriver.php b/lib/NWNDriver.php index 017e5c3..b04790d 100644 --- a/lib/NWNDriver.php +++ b/lib/NWNDriver.php @@ -225,14 +225,32 @@ class NWNDriver return $data; } - function useModule($moduleName) + function useModule($moduleName, $flush = false) { $settings = &$this->_settingsbackend->getSettings(); $settings['module'] = $moduleName; if ($this->serverRunning()) { - $this->sendCommand('module ' . $moduleName); + $this->sendCommand('module ' . $moduleName, $flush); + sleep(2); + $result = $this->getLogContent(); + $lines = explode("\n", $result); + $found = false; + foreach ($lines as $l) { + $l = trim($l); + if (!strpos($l, $moduleName) && strpos($l, 'Module loaded')) { + $found = true; + } + } + if (!$found) { + unset($settings['module']); + $this->_settingsbackend->setData($settings); + return PEAR::raiseError(_("Could not load the module!")); + } + } else { + $result = PEAR::raiseError(_("Server is not running!")); } - return $this->_settingsbackend->setData($settings); + $this->_settingsbackend->setData($settings); + return true; } function getModule() diff --git a/module.php b/module.php index 7158a86..6b64d7b 100644 --- a/module.php +++ b/module.php @@ -39,7 +39,7 @@ if (isset($actionId) && !isset($moduleName)) { break; case 'activate': if ($admin) { - $result = $nwndriver->useModule($moduleName); + $result = $nwndriver->useModule($moduleName, true); if (is_a($result, 'PEAR_Error')) { $notification->push( _("Module load failure: ") . diff --git a/start.php b/start.php index 45f2b15..242620b 100644 --- a/start.php +++ b/start.php @@ -26,7 +26,6 @@ if (!$params || is_a($params, 'PEAR_Error') || $actionId = Util::getFormData('actionId'); switch ($actionId) { case 'stop': -case 'restart': $wait = true; $result = $nwndriver->stopServer(); if (is_a($result, 'PEAR_Error')) { @@ -35,7 +34,7 @@ case 'restart': } else { $notification->push(_("The server was stopped."), 'horde.success'); } - if ($actionId == 'stop') { break; } + break; case 'start': $wait = true; $result = $nwndriver->startServer(); diff --git a/templates/start/kill.inc b/templates/start/kill.inc index 7fc001b..a6a12b7 100644 --- a/templates/start/kill.inc +++ b/templates/start/kill.inc @@ -8,16 +8,6 @@ class="button" />
-
- - -
Restart Server
- -
-
@@ -36,4 +26,4 @@ class="item0"> -
Kill Server
\ No newline at end of file +