2013-11-10 17:29:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl;
|
|
|
|
|
2014-01-27 20:28:37 +01:00
|
|
|
use ErrorHandler;
|
2013-12-31 12:42:07 +01:00
|
|
|
use ManiaControl\Admin\ActionsMenu;
|
2013-11-13 01:43:12 +01:00
|
|
|
use ManiaControl\Admin\AuthenticationManager;
|
2013-11-12 15:48:25 +01:00
|
|
|
use ManiaControl\Callbacks\CallbackManager;
|
2013-11-24 23:55:54 +01:00
|
|
|
use ManiaControl\Commands\CommandListener;
|
2013-11-12 15:48:25 +01:00
|
|
|
use ManiaControl\Commands\CommandManager;
|
2013-11-28 03:47:08 +01:00
|
|
|
use ManiaControl\Configurators\Configurator;
|
|
|
|
use ManiaControl\Manialinks\ManialinkManager;
|
2013-11-12 15:48:25 +01:00
|
|
|
use ManiaControl\Maps\MapManager;
|
2013-11-24 23:55:54 +01:00
|
|
|
use ManiaControl\Players\Player;
|
2013-11-13 01:43:12 +01:00
|
|
|
use ManiaControl\Players\PlayerManager;
|
2013-11-12 15:48:25 +01:00
|
|
|
use ManiaControl\Plugins\PluginManager;
|
2013-11-19 20:29:37 +01:00
|
|
|
use ManiaControl\Server\Server;
|
2014-01-27 17:29:48 +01:00
|
|
|
use ManiaControl\Settings\SettingManager;
|
2014-01-01 17:59:29 +01:00
|
|
|
use ManiaControl\Statistics\StatisticManager;
|
2014-01-16 17:19:01 +01:00
|
|
|
use Maniaplanet\DedicatedServer\Connection;
|
2014-01-17 16:32:53 +01:00
|
|
|
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
2013-12-31 12:42:07 +01:00
|
|
|
|
2014-01-16 17:19:01 +01:00
|
|
|
require_once __DIR__ . '/Maniaplanet/DedicatedServer/Connection.php';
|
2013-12-17 17:38:44 +01:00
|
|
|
require_once __DIR__ . '/GbxDataFetcher/gbxdatafetcher.inc.php';
|
2014-01-27 09:08:07 +01:00
|
|
|
require_once __DIR__ . '/FML/autoload.php';
|
2013-11-10 17:29:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ManiaControl Server Controller for ManiaPlanet Server
|
|
|
|
*
|
2013-11-12 15:48:25 +01:00
|
|
|
* @author steeffeen & kremsy
|
2013-11-10 17:29:21 +01:00
|
|
|
*/
|
2013-11-24 23:55:54 +01:00
|
|
|
class ManiaControl implements CommandListener {
|
2013-11-10 17:29:21 +01:00
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
2014-01-27 17:29:48 +01:00
|
|
|
const VERSION = '0.01';
|
|
|
|
const API_VERSION = '2013-04-16';
|
|
|
|
const OS_UNIX = 'Unix';
|
|
|
|
const OS_WIN = 'Windows';
|
2014-01-18 22:06:07 +01:00
|
|
|
const CONNECT_TIMEOUT = 20;
|
2014-01-27 17:29:48 +01:00
|
|
|
const SCRIPT_TIMEOUT = 20;
|
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
/**
|
|
|
|
* Public properties
|
|
|
|
*/
|
2013-12-31 12:42:07 +01:00
|
|
|
public $actionsMenu = null;
|
2013-11-13 01:43:12 +01:00
|
|
|
public $authenticationManager = null;
|
2013-11-12 15:48:25 +01:00
|
|
|
public $callbackManager = null;
|
2013-11-10 17:29:21 +01:00
|
|
|
public $chat = null;
|
2014-01-06 14:22:48 +01:00
|
|
|
public $config = null;
|
2013-11-28 03:47:08 +01:00
|
|
|
public $configurator = null;
|
2014-01-27 17:29:48 +01:00
|
|
|
/** @var Connection $client */
|
2013-11-10 17:29:21 +01:00
|
|
|
public $client = null;
|
2013-11-12 15:48:25 +01:00
|
|
|
public $commandManager = null;
|
2013-11-10 17:29:21 +01:00
|
|
|
public $database = null;
|
2013-11-28 02:04:06 +01:00
|
|
|
public $manialinkManager = null;
|
2013-11-12 15:48:25 +01:00
|
|
|
public $mapManager = null;
|
|
|
|
public $playerManager = null;
|
|
|
|
public $pluginManager = null;
|
2013-11-10 17:29:21 +01:00
|
|
|
public $server = null;
|
|
|
|
public $settingManager = null;
|
2013-12-31 17:31:05 +01:00
|
|
|
public $statisticManager = null;
|
2013-12-17 17:38:44 +01:00
|
|
|
public $updateManager = null;
|
2014-01-27 20:28:37 +01:00
|
|
|
public $errorHandler = null;
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
/**
|
|
|
|
* Private properties
|
|
|
|
*/
|
|
|
|
private $shutdownRequested = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct ManiaControl
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
2014-01-27 20:28:37 +01:00
|
|
|
//Construct Error Handler
|
|
|
|
$this->errorHandler = new ErrorHandler($this);
|
|
|
|
|
2013-12-31 14:50:45 +01:00
|
|
|
$this->log('Loading ManiaControl v' . self::VERSION . '...');
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-06 14:22:48 +01:00
|
|
|
// Load config
|
|
|
|
$this->config = FileUtil::loadConfig('server.xml');
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-12-17 17:38:44 +01:00
|
|
|
// Load ManiaControl Modules
|
2014-01-27 17:29:48 +01:00
|
|
|
$this->database = new Database($this);
|
|
|
|
$this->callbackManager = new CallbackManager($this);
|
|
|
|
$this->settingManager = new SettingManager($this);
|
|
|
|
$this->statisticManager = new StatisticManager($this);
|
|
|
|
$this->manialinkManager = new ManialinkManager($this);
|
|
|
|
$this->actionsMenu = new ActionsMenu($this);
|
|
|
|
$this->chat = new Chat($this);
|
|
|
|
$this->commandManager = new CommandManager($this);
|
|
|
|
$this->server = new Server($this);
|
2013-11-26 13:49:36 +01:00
|
|
|
$this->authenticationManager = new AuthenticationManager($this);
|
2014-01-27 17:29:48 +01:00
|
|
|
$this->playerManager = new PlayerManager($this);
|
|
|
|
$this->mapManager = new MapManager($this);
|
|
|
|
$this->configurator = new Configurator($this);
|
|
|
|
$this->pluginManager = new PluginManager($this);
|
|
|
|
$this->updateManager = new UpdateManager($this);
|
|
|
|
|
2013-12-17 17:38:44 +01:00
|
|
|
// Register for commands
|
2013-11-24 23:55:54 +01:00
|
|
|
$this->commandManager->registerCommandListener('version', $this, 'command_Version');
|
2014-01-01 17:59:29 +01:00
|
|
|
$this->commandManager->registerCommandListener('restart', $this, 'command_Restart', true);
|
2014-01-01 19:25:51 +01:00
|
|
|
$this->commandManager->registerCommandListener('shutdown', $this, 'command_Shutdown', true);
|
2013-11-10 17:29:21 +01:00
|
|
|
}
|
|
|
|
|
2014-01-27 20:28:37 +01:00
|
|
|
|
2013-12-09 15:53:10 +01:00
|
|
|
/**
|
|
|
|
* Print a message to console and log
|
2013-12-31 12:42:07 +01:00
|
|
|
*
|
|
|
|
* @param string $message
|
2013-12-09 15:53:10 +01:00
|
|
|
*/
|
2014-01-05 14:13:18 +01:00
|
|
|
public function log($message, $stripCodes = false) {
|
2014-01-10 13:21:07 +01:00
|
|
|
$date = date("d.M y H:i:s");
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($stripCodes) {
|
2014-01-05 14:13:18 +01:00
|
|
|
$message = Formatter::stripCodes($message);
|
|
|
|
}
|
2014-01-10 13:21:07 +01:00
|
|
|
logMessage($date . ' ' . $message);
|
2013-12-09 15:53:10 +01:00
|
|
|
}
|
|
|
|
|
2014-01-01 17:59:29 +01:00
|
|
|
/**
|
|
|
|
* Get the Operating System on which ManiaControl is running
|
|
|
|
*
|
|
|
|
* @param string $compareOS
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getOS($compareOS = null) {
|
|
|
|
$windows = defined('PHP_WINDOWS_VERSION_MAJOR');
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($compareOS) {
|
2014-01-01 17:59:29 +01:00
|
|
|
// Return bool whether OS equals $compareOS
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($compareOS == self::OS_WIN) {
|
2014-01-01 17:59:29 +01:00
|
|
|
return $windows;
|
|
|
|
}
|
|
|
|
return !$windows;
|
|
|
|
}
|
|
|
|
// Return OS
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($windows) {
|
2014-01-01 17:59:29 +01:00
|
|
|
return self::OS_WIN;
|
|
|
|
}
|
|
|
|
return self::OS_UNIX;
|
|
|
|
}
|
|
|
|
|
2013-11-24 23:55:54 +01:00
|
|
|
/**
|
2014-01-01 17:59:29 +01:00
|
|
|
* Handle Version Command
|
2013-11-24 23:55:54 +01:00
|
|
|
*
|
2014-01-27 17:29:48 +01:00
|
|
|
* @param array $chatCallback
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param Player $player
|
2013-11-24 23:55:54 +01:00
|
|
|
*/
|
2014-01-01 17:59:29 +01:00
|
|
|
public function command_Version(array $chatCallback, Player $player) {
|
2013-11-24 23:55:54 +01:00
|
|
|
$message = 'This server is using ManiaControl v' . ManiaControl::VERSION . '!';
|
2014-01-01 17:59:29 +01:00
|
|
|
$this->chat->sendInformation($message, $player->login);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Restart AdminCommand
|
|
|
|
*
|
2014-01-27 17:29:48 +01:00
|
|
|
* @param array $chatCallback
|
2014-01-01 17:59:29 +01:00
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function command_Restart(array $chatCallback, Player $player) {
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
2014-01-01 17:59:29 +01:00
|
|
|
$this->authenticationManager->sendNotAllowed($player);
|
|
|
|
return;
|
|
|
|
}
|
2014-01-01 19:25:51 +01:00
|
|
|
$this->restart("ManiaControl Restart requested by '{$player->login}'!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //shutdown command
|
|
|
|
*
|
2014-01-27 17:29:48 +01:00
|
|
|
* @param array $chat
|
2014-01-01 19:25:51 +01:00
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function command_Shutdown(array $chat, Player $player) {
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!$this->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
2014-01-01 19:25:51 +01:00
|
|
|
$this->authenticationManager->sendNotAllowed($player);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->quit("ManiaControl Shutdown requested by '{$player->login}'!");
|
2013-11-24 23:55:54 +01:00
|
|
|
}
|
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
/**
|
|
|
|
* Quit ManiaControl and log the given message
|
2013-12-09 13:45:58 +01:00
|
|
|
*
|
2013-12-31 12:42:07 +01:00
|
|
|
* @param string $message
|
2013-11-10 17:29:21 +01:00
|
|
|
*/
|
2014-01-01 19:25:51 +01:00
|
|
|
public function quit($message = null) {
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($message) {
|
2014-01-10 13:08:26 +01:00
|
|
|
$this->log($message);
|
|
|
|
}
|
2014-01-01 19:25:51 +01:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle PHP Process Shutdown
|
|
|
|
*/
|
|
|
|
public function handleShutdown() {
|
2013-12-09 15:43:08 +01:00
|
|
|
// OnShutdown callback
|
|
|
|
$this->callbackManager->triggerCallback(CallbackManager::CB_MC_ONSHUTDOWN, array(CallbackManager::CB_MC_ONSHUTDOWN));
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-01 19:25:51 +01:00
|
|
|
// Announce quit
|
|
|
|
$this->chat->sendInformation('ManiaControl shutting down.');
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-01 19:25:51 +01:00
|
|
|
// Hide manialinks
|
2014-01-16 17:19:01 +01:00
|
|
|
$this->client->sendHideManialinkPage();
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-27 09:08:07 +01:00
|
|
|
// Close the client connection
|
2014-01-20 20:51:03 +01:00
|
|
|
$this->client->delete($this->server->ip, $this->server->port);
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-12-31 18:24:40 +01:00
|
|
|
$this->log('Quitting ManiaControl!');
|
2013-11-10 17:29:21 +01:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2014-01-01 17:59:29 +01:00
|
|
|
/**
|
|
|
|
* Restart ManiaControl
|
|
|
|
*
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function restart($message = null) {
|
|
|
|
// Shutdown callback
|
|
|
|
$this->callbackManager->triggerCallback(CallbackManager::CB_MC_ONSHUTDOWN, array(CallbackManager::CB_MC_ONSHUTDOWN));
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-01 17:59:29 +01:00
|
|
|
// Announce restart
|
|
|
|
$this->chat->sendInformation('Restarting ManiaControl...');
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($message) {
|
2014-01-10 13:08:26 +01:00
|
|
|
$this->log($message);
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-01 17:59:29 +01:00
|
|
|
// Hide widgets
|
2014-01-16 17:19:01 +01:00
|
|
|
$this->client->sendHideManialinkPage();
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-01 19:25:51 +01:00
|
|
|
$this->log('Restarting ManiaControl!');
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-01 17:59:29 +01:00
|
|
|
// Execute start script in background
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($this->getOS(self::OS_UNIX)) {
|
2014-01-01 17:59:29 +01:00
|
|
|
$command = 'sh ' . escapeshellarg(ManiaControlDir . '/ManiaControl.sh') . ' > /dev/null &';
|
|
|
|
exec($command);
|
2014-01-27 17:29:48 +01:00
|
|
|
} else {
|
2014-01-20 20:51:03 +01:00
|
|
|
$command = escapeshellarg(ManiaControlDir . "\ManiaControl.bat");
|
2014-01-27 09:08:07 +01:00
|
|
|
system($command); // TODO, windows stucks here as long controller is running
|
2014-01-01 17:59:29 +01:00
|
|
|
}
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
/**
|
|
|
|
* Run ManiaControl
|
|
|
|
*/
|
|
|
|
public function run() {
|
2013-12-31 18:24:40 +01:00
|
|
|
$this->log('Starting ManiaControl v' . self::VERSION . '!');
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Connect to server
|
|
|
|
$this->connect();
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-12-09 15:43:08 +01:00
|
|
|
// Register shutdown handler
|
2014-01-01 19:25:51 +01:00
|
|
|
register_shutdown_function(array($this, 'handleShutdown'));
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-12-09 15:43:08 +01:00
|
|
|
// OnInit callback
|
2013-11-12 15:48:25 +01:00
|
|
|
$this->callbackManager->triggerCallback(CallbackManager::CB_MC_ONINIT, array(CallbackManager::CB_MC_ONINIT));
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-18 10:26:32 +01:00
|
|
|
// Load plugins
|
|
|
|
$this->pluginManager->loadPlugins();
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-10 13:08:26 +01:00
|
|
|
// Announce ManiaControl
|
|
|
|
$this->chat->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!');
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-10 13:08:26 +01:00
|
|
|
// Loading finished
|
|
|
|
$this->log('Loading completed!');
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Main loop
|
2014-01-27 17:29:48 +01:00
|
|
|
while(!$this->shutdownRequested) {
|
2013-11-10 17:29:21 +01:00
|
|
|
$loopStart = microtime(true);
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Disable script timeout
|
2014-01-20 20:51:03 +01:00
|
|
|
set_time_limit(self::SCRIPT_TIMEOUT);
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-12 15:48:25 +01:00
|
|
|
// Manager callbacks
|
|
|
|
$this->callbackManager->manageCallbacks();
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Yield for next tick
|
2014-01-27 17:29:48 +01:00
|
|
|
$loopEnd = microtime(true);
|
2014-01-29 16:23:00 +01:00
|
|
|
$sleepTime = 1000 - $loopEnd + $loopStart;
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($sleepTime > 0) {
|
2013-11-10 17:29:21 +01:00
|
|
|
usleep($sleepTime);
|
|
|
|
}
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Shutdown
|
2013-12-09 15:43:08 +01:00
|
|
|
$this->quit();
|
2013-11-10 17:29:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Connect to ManiaPlanet server
|
|
|
|
*/
|
|
|
|
private function connect() {
|
|
|
|
// Load remote client
|
2014-01-06 14:22:48 +01:00
|
|
|
$host = $this->config->server->xpath('host');
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!$host) {
|
2014-01-10 13:08:26 +01:00
|
|
|
trigger_error("Invalid server configuration (host).", E_USER_ERROR);
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
$host = (string)$host[0];
|
2014-01-06 14:22:48 +01:00
|
|
|
$port = $this->config->server->xpath('port');
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!$host) {
|
2014-01-10 13:08:26 +01:00
|
|
|
trigger_error("Invalid server configuration (port).", E_USER_ERROR);
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
$port = (string)$port[0];
|
|
|
|
|
2013-12-31 14:50:45 +01:00
|
|
|
$this->log("Connecting to server at {$host}:{$port}...");
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-06 14:22:48 +01:00
|
|
|
$login = $this->config->server->xpath('login');
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!$login) {
|
2014-01-10 13:08:26 +01:00
|
|
|
trigger_error("Invalid server configuration (login).", E_USER_ERROR);
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
$login = (string)$login[0];
|
|
|
|
$pass = $this->config->server->xpath('pass');
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!$pass) {
|
2014-01-10 13:08:26 +01:00
|
|
|
trigger_error("Invalid server configuration (password).", E_USER_ERROR);
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
$pass = (string)$pass[0];
|
|
|
|
|
2014-01-17 16:32:53 +01:00
|
|
|
try {
|
2014-01-18 22:06:07 +01:00
|
|
|
$this->client = Connection::factory($host, $port, self::CONNECT_TIMEOUT, $login, $pass);
|
2014-01-27 17:29:48 +01:00
|
|
|
} catch(Exception $e) {
|
2014-01-17 16:32:53 +01:00
|
|
|
trigger_error("Couldn't authenticate on server with user '{$login}'! " . $e->getMessage(), E_USER_ERROR);
|
2013-11-10 17:29:21 +01:00
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Enable callback system
|
2014-01-17 16:32:53 +01:00
|
|
|
try {
|
|
|
|
$this->client->enableCallbacks(true);
|
2014-01-27 17:29:48 +01:00
|
|
|
} catch(Exception $e) {
|
2014-01-17 16:32:53 +01:00
|
|
|
trigger_error("Couldn't enable callbacks! " . $e->getMessage(), E_USER_ERROR);
|
2013-11-10 17:29:21 +01:00
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Wait for server to be ready
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!$this->server->waitForStatus(4)) {
|
2013-11-10 17:29:21 +01:00
|
|
|
trigger_error("Server couldn't get ready!", E_USER_ERROR);
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Set api version
|
2014-01-27 09:08:07 +01:00
|
|
|
/*
|
|
|
|
* if(!$this->client->query('SetApiVersion', self::API_VERSION)) { trigger_error("Couldn't set API version '" . self::API_VERSION . "'! This
|
|
|
|
* might cause problems. " . $this->getClientErrorText()); }
|
|
|
|
*/
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Connect finished
|
2013-12-31 14:50:45 +01:00
|
|
|
$this->log("Server Connection successfully established!");
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-12-31 14:50:45 +01:00
|
|
|
// Hide old widgets
|
2014-01-16 17:19:01 +01:00
|
|
|
$this->client->sendHideManialinkPage();
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-11-10 17:29:21 +01:00
|
|
|
// Enable script callbacks if needed
|
2014-01-27 20:28:37 +01:00
|
|
|
if ($this->server->getGameMode() != 0) {
|
2014-01-10 13:08:26 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-17 16:32:53 +01:00
|
|
|
try {
|
|
|
|
$scriptSettings = $this->client->getModeScriptSettings();
|
2014-01-27 17:29:48 +01:00
|
|
|
} catch(Exception $e) {
|
2014-01-17 16:32:53 +01:00
|
|
|
trigger_error("Couldn't get mode script settings. " . $e->getMessage());
|
2013-12-09 15:43:08 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2014-01-27 20:28:37 +01:00
|
|
|
if (!array_key_exists('S_UseScriptCallbacks', $scriptSettings)) {
|
2014-01-10 13:08:26 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-27 17:29:48 +01:00
|
|
|
|
2013-12-09 15:43:08 +01:00
|
|
|
$scriptSettings['S_UseScriptCallbacks'] = true;
|
2014-01-17 16:32:53 +01:00
|
|
|
try {
|
|
|
|
$this->client->setModeScriptSettings($scriptSettings);
|
2014-01-27 17:29:48 +01:00
|
|
|
} catch(Exception $e) {
|
2014-01-18 22:06:07 +01:00
|
|
|
trigger_error("Couldn't set mode script settings to enable script callbacks. " . $e->getMessage());
|
2013-12-09 15:43:08 +01:00
|
|
|
return;
|
2013-11-10 17:29:21 +01:00
|
|
|
}
|
2013-12-31 14:50:45 +01:00
|
|
|
$this->log('Script Callbacks successfully enabled!');
|
2013-11-10 17:29:21 +01:00
|
|
|
}
|
|
|
|
}
|