2014-01-02 23:49:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Configurators;
|
|
|
|
|
2014-05-15 23:05:57 +02:00
|
|
|
use FML\Components\CheckBox;
|
2014-01-02 23:49:21 +01:00
|
|
|
use FML\Controls\Entry;
|
|
|
|
use FML\Controls\Frame;
|
|
|
|
use FML\Controls\Labels\Label_Text;
|
2014-05-15 23:05:57 +02:00
|
|
|
use FML\Controls\Quad;
|
2014-01-02 23:49:21 +01:00
|
|
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
2014-04-27 16:22:12 +02:00
|
|
|
use FML\Script\Features\Paging;
|
2014-01-02 23:49:21 +01:00
|
|
|
use FML\Script\Script;
|
2014-04-13 19:05:54 +02:00
|
|
|
use ManiaControl\Admin\AuthenticationManager;
|
2014-01-02 23:49:21 +01:00
|
|
|
use ManiaControl\Callbacks\CallbackListener;
|
2014-05-24 16:39:12 +02:00
|
|
|
use ManiaControl\Callbacks\Callbacks;
|
2014-01-02 23:49:21 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Players\Player;
|
2014-05-20 15:42:10 +02:00
|
|
|
use Maniaplanet\DedicatedServer\Structures\ServerOptions;
|
2014-05-08 21:10:56 +02:00
|
|
|
use Maniaplanet\DedicatedServer\Xmlrpc\ServerOptionsException;
|
2014-01-31 16:11:14 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
/**
|
|
|
|
* Class offering a Configurator for Server Settings
|
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
|
|
* @copyright 2014 ManiaControl Team
|
2014-04-13 19:05:54 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-01-02 23:49:21 +01:00
|
|
|
*/
|
|
|
|
class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-01-02 23:49:21 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2014-05-15 23:05:57 +02:00
|
|
|
const ACTION_PREFIX_SETTING = 'ServerSettings.';
|
2014-04-13 19:05:54 +02:00
|
|
|
const CB_SERVERSETTING_CHANGED = 'ServerSettings.SettingChanged';
|
|
|
|
const CB_SERVERSETTINGS_CHANGED = 'ServerSettings.SettingsChanged';
|
|
|
|
const TABLE_SERVER_SETTINGS = 'mc_serversettings';
|
|
|
|
const SETTING_PERMISSION_CHANGE_SERVER_SETTINGS = 'Change Server-Settings';
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-01-02 23:49:21 +01:00
|
|
|
* Private Properties
|
|
|
|
*/
|
|
|
|
private $maniaControl = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new Server Settings Instance
|
|
|
|
*
|
|
|
|
* @param ManiaControl $maniaControl
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-01-05 12:21:40 +01:00
|
|
|
$this->initTables();
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
// Register for callbacks
|
2014-05-24 16:39:12 +02:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
|
2014-04-13 19:05:54 +02:00
|
|
|
|
|
|
|
//Permission for Change Script-Settings
|
|
|
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_SERVER_SETTINGS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
2014-01-04 17:18:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize necessary database tables
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function initTables() {
|
2014-01-05 20:34:48 +01:00
|
|
|
$mysqli = $this->maniaControl->database->mysqli;
|
|
|
|
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_SERVER_SETTINGS . "` (
|
2014-02-13 14:58:04 +01:00
|
|
|
`index` int(11) NOT NULL AUTO_INCREMENT,
|
|
|
|
`serverIndex` int(11) NOT NULL,
|
|
|
|
`settingName` varchar(100) NOT NULL,
|
|
|
|
`settingValue` varchar(500) NOT NULL,
|
|
|
|
PRIMARY KEY (`index`),
|
2014-01-05 14:41:19 +01:00
|
|
|
UNIQUE KEY `setting` (`serverIndex`, `settingName`)
|
2014-01-04 17:18:11 +01:00
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Server Settings' AUTO_INCREMENT=1;";
|
|
|
|
$statement = $mysqli->prepare($query);
|
2014-02-01 20:03:17 +01:00
|
|
|
if ($mysqli->error) {
|
2014-01-04 17:18:11 +01:00
|
|
|
trigger_error($mysqli->error, E_USER_ERROR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$statement->execute();
|
2014-02-01 20:03:17 +01:00
|
|
|
if ($statement->error) {
|
2014-01-04 17:18:11 +01:00
|
|
|
trigger_error($statement->error, E_USER_ERROR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$statement->close();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-24 23:13:30 +02:00
|
|
|
/**
|
|
|
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
|
|
|
|
*/
|
|
|
|
public static function getTitle() {
|
|
|
|
return 'Server Settings';
|
|
|
|
}
|
|
|
|
|
2014-01-04 17:18:11 +01:00
|
|
|
/**
|
|
|
|
* Handle OnInit callback
|
|
|
|
*/
|
2014-02-19 15:44:00 +01:00
|
|
|
public function onInit() {
|
2014-01-04 17:18:11 +01:00
|
|
|
$this->loadSettingsFromDatabase();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load Settings from Database
|
2014-01-04 17:30:29 +01:00
|
|
|
*
|
2014-01-04 17:18:11 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function loadSettingsFromDatabase() {
|
2014-07-25 15:17:36 +02:00
|
|
|
$mysqli = $this->maniaControl->database->mysqli;
|
|
|
|
$query = "SELECT * FROM `" . self::TABLE_SERVER_SETTINGS . "`
|
|
|
|
WHERE serverIndex = {$this->maniaControl->server->index};";
|
|
|
|
$result = $mysqli->query($query);
|
2014-02-01 20:03:17 +01:00
|
|
|
if ($mysqli->error) {
|
2014-01-04 17:18:11 +01:00
|
|
|
trigger_error($mysqli->error);
|
2014-01-05 12:21:40 +01:00
|
|
|
return false;
|
2014-01-04 17:18:11 +01:00
|
|
|
}
|
2014-07-25 15:17:36 +02:00
|
|
|
|
|
|
|
$oldServerOptions = $this->maniaControl->client->getServerOptions();
|
|
|
|
$newServerOptions = new ServerOptions();
|
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
while ($row = $result->fetch_object()) {
|
2014-06-29 17:12:43 +02:00
|
|
|
$settingName = lcfirst($row->settingName);
|
2014-07-25 15:17:36 +02:00
|
|
|
if (!property_exists($oldServerOptions, $settingName)) {
|
2014-01-05 20:34:48 +01:00
|
|
|
continue;
|
|
|
|
}
|
2014-07-25 15:17:36 +02:00
|
|
|
$newServerOptions->$settingName = $row->settingValue;
|
|
|
|
settype($newServerOptions->$settingName, gettype($oldServerOptions->$settingName));
|
2014-01-04 17:18:11 +01:00
|
|
|
}
|
2014-05-18 23:34:47 +02:00
|
|
|
$result->free();
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-25 15:17:36 +02:00
|
|
|
$this->fillUpMandatoryOptions($newServerOptions, $oldServerOptions);
|
|
|
|
|
|
|
|
$loaded = false;
|
2014-05-20 14:59:17 +02:00
|
|
|
try {
|
2014-07-25 15:17:36 +02:00
|
|
|
$loaded = $this->maniaControl->client->setServerOptions($newServerOptions);
|
2014-05-20 14:59:17 +02:00
|
|
|
} catch (ServerOptionsException $exception) {
|
|
|
|
$this->maniaControl->chat->sendExceptionToAdmins($exception);
|
|
|
|
}
|
2014-07-25 15:17:36 +02:00
|
|
|
$message = ($loaded ? 'Server Settings successfully loaded!' : 'Error loading Server Settings!');
|
|
|
|
$this->maniaControl->chat->sendSuccessToAdmins($message);
|
|
|
|
return $loaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill up the new server options object with the necessary settings based on the old options object
|
|
|
|
*
|
|
|
|
* @param ServerOptions $newServerOptions
|
|
|
|
* @param ServerOptions $oldServerOptions
|
|
|
|
* @return ServerOptions
|
|
|
|
*/
|
|
|
|
private function fillUpMandatoryOptions(ServerOptions &$newServerOptions, ServerOptions $oldServerOptions) {
|
|
|
|
$mandatorySettings = array('name', 'comment', 'password', 'passwordForSpectator', 'nextCallVoteTimeOut', 'callVoteRatio');
|
|
|
|
foreach ($mandatorySettings as $settingName) {
|
|
|
|
if (!isset($newServerOptions->$settingName) && isset($oldServerOptions->$settingName)) {
|
|
|
|
$newServerOptions->$settingName = $oldServerOptions->$settingName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $newServerOptions;
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
|
|
|
|
*/
|
2014-04-30 05:27:23 +02:00
|
|
|
public function getMenu($width, $height, Script $script, Player $player) {
|
2014-05-02 17:50:30 +02:00
|
|
|
$paging = new Paging();
|
|
|
|
$script->addFeature($paging);
|
|
|
|
$frame = new Frame();
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-24 23:13:30 +02:00
|
|
|
$serverOptions = $this->maniaControl->client->getServerOptions();
|
|
|
|
$serverSettings = $serverOptions->toArray();
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
// Config
|
2014-01-05 20:34:48 +01:00
|
|
|
$pagerSize = 9.;
|
2014-01-02 23:49:21 +01:00
|
|
|
$settingHeight = 5.;
|
|
|
|
$labelTextSize = 2;
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
// Pagers
|
|
|
|
$pagerPrev = new Quad_Icons64x64_1();
|
|
|
|
$frame->add($pagerPrev);
|
2014-07-24 23:13:30 +02:00
|
|
|
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2)
|
|
|
|
->setSize($pagerSize, $pagerSize)
|
|
|
|
->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
$pagerNext = new Quad_Icons64x64_1();
|
|
|
|
$frame->add($pagerNext);
|
2014-07-24 23:13:30 +02:00
|
|
|
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2)
|
|
|
|
->setSize($pagerSize, $pagerSize)
|
|
|
|
->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-06-22 19:02:18 +02:00
|
|
|
$pageCountLabel = new Label_Text();
|
2014-01-02 23:49:21 +01:00
|
|
|
$frame->add($pageCountLabel);
|
2014-07-24 23:13:30 +02:00
|
|
|
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)
|
|
|
|
->setPosition($width * 0.35, $height * -0.44, 1)
|
|
|
|
->setStyle($pageCountLabel::STYLE_TextTitle1)
|
|
|
|
->setTextSize(2);
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-24 23:13:30 +02:00
|
|
|
$paging->addButton($pagerNext)
|
|
|
|
->addButton($pagerPrev)
|
|
|
|
->setLabel($pageCountLabel);
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
// Setting pages
|
2014-06-17 23:55:59 +02:00
|
|
|
$posY = 0.;
|
|
|
|
$index = 0;
|
2014-05-15 17:45:08 +02:00
|
|
|
$pageFrame = null;
|
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
foreach ($serverSettings as $name => $value) {
|
2014-01-05 12:21:40 +01:00
|
|
|
// Continue on CurrentMaxPlayers...
|
2014-07-24 23:13:30 +02:00
|
|
|
$pos = strpos($name, 'Current'); // TODO: display 'Current...' somewhere
|
2014-02-01 20:03:17 +01:00
|
|
|
if ($pos !== false) {
|
2014-01-02 23:49:21 +01:00
|
|
|
continue;
|
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-06-17 23:55:59 +02:00
|
|
|
if ($index % 13 === 0) {
|
2014-01-02 23:49:21 +01:00
|
|
|
$pageFrame = new Frame();
|
|
|
|
$frame->add($pageFrame);
|
2014-06-17 23:55:59 +02:00
|
|
|
$posY = $height * 0.41;
|
2014-05-02 17:50:30 +02:00
|
|
|
$paging->addPage($pageFrame);
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
$settingFrame = new Frame();
|
|
|
|
$pageFrame->add($settingFrame);
|
2014-06-17 23:55:59 +02:00
|
|
|
$settingFrame->setY($posY);
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
$nameLabel = new Label_Text();
|
|
|
|
$settingFrame->add($nameLabel);
|
2014-07-24 23:13:30 +02:00
|
|
|
$nameLabel->setHAlign($nameLabel::LEFT)
|
|
|
|
->setX($width * -0.46)
|
|
|
|
->setSize($width * 0.4, $settingHeight)
|
|
|
|
->setStyle($nameLabel::STYLE_TextCardSmall)
|
|
|
|
->setTextSize($labelTextSize)
|
|
|
|
->setText($name)
|
|
|
|
->setTextColor('fff');
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-05-15 23:05:57 +02:00
|
|
|
if (is_bool($value)) {
|
|
|
|
// Boolean checkbox
|
|
|
|
$quad = new Quad();
|
2014-07-24 23:13:30 +02:00
|
|
|
$quad->setPosition($width * 0.23, 0, -0.01)
|
|
|
|
->setSize(4, 4);
|
2014-05-18 19:45:50 +02:00
|
|
|
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $name, $value, $quad);
|
|
|
|
$settingFrame->add($checkBox);
|
2014-05-15 23:05:57 +02:00
|
|
|
} else {
|
|
|
|
// Other
|
|
|
|
$entry = new Entry();
|
|
|
|
$settingFrame->add($entry);
|
2014-07-24 23:13:30 +02:00
|
|
|
$entry->setStyle(Label_Text::STYLE_TextValueSmall)
|
|
|
|
->setX($width * 0.23)
|
|
|
|
->setTextSize(1)
|
|
|
|
->setSize($width * 0.48, $settingHeight * 0.9)
|
|
|
|
->setName(self::ACTION_PREFIX_SETTING . $name)
|
|
|
|
->setDefault($value);
|
2014-05-15 23:05:57 +02:00
|
|
|
|
2014-06-14 14:32:29 +02:00
|
|
|
if ($name === 'Comment') {
|
2014-07-24 23:13:30 +02:00
|
|
|
$entry->setSize($width * 0.48, $settingHeight * 3. + $settingHeight * 0.9)
|
|
|
|
->setAutoNewLine(true);
|
2014-06-17 23:55:59 +02:00
|
|
|
$settingFrame->setY($posY - $settingHeight * 1.5);
|
2014-07-24 23:13:30 +02:00
|
|
|
$posY -= $settingHeight * 3.;
|
2014-06-17 23:55:59 +02:00
|
|
|
$index += 3;
|
2014-05-15 23:05:57 +02:00
|
|
|
}
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-06-17 23:55:59 +02:00
|
|
|
$posY -= $settingHeight;
|
|
|
|
$index++;
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
return $frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
|
|
|
*/
|
|
|
|
public function saveConfigData(array $configData, Player $player) {
|
2014-04-13 19:05:54 +02:00
|
|
|
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SERVER_SETTINGS)) {
|
|
|
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
|
|
|
return;
|
|
|
|
}
|
2014-04-30 05:27:23 +02:00
|
|
|
if (!$configData[3] || strpos($configData[3][0]['Name'], self::ACTION_PREFIX_SETTING) !== 0) {
|
2014-01-05 20:34:48 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-02 23:49:21 +01:00
|
|
|
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-25 15:17:36 +02:00
|
|
|
$oldServerOptions = $this->maniaControl->client->getServerOptions();
|
|
|
|
$newServerOptions = new ServerOptions();
|
2014-05-25 09:58:52 +02:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
foreach ($configData[3] as $setting) {
|
2014-07-25 15:17:36 +02:00
|
|
|
$settingName = lcfirst(substr($setting['Name'], $prefixLength));
|
|
|
|
$newServerOptions->$settingName = $setting['Value'];
|
|
|
|
settype($newServerOptions->$settingName, gettype($oldServerOptions->$settingName));
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-25 15:17:36 +02:00
|
|
|
$this->fillUpMandatoryOptions($newServerOptions, $oldServerOptions);
|
|
|
|
|
|
|
|
$success = $this->applyNewServerOptions($newServerOptions, $player);
|
2014-05-16 20:42:37 +02:00
|
|
|
if ($success) {
|
|
|
|
$this->maniaControl->chat->sendSuccess('Server Settings saved!', $player);
|
|
|
|
} else {
|
2014-07-24 23:13:30 +02:00
|
|
|
$this->maniaControl->chat->sendSuccess('Server Settings saving failed!', $player);
|
2014-05-16 20:42:37 +02:00
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-05-16 20:42:37 +02:00
|
|
|
// Reopen the Menu
|
2014-07-24 23:13:30 +02:00
|
|
|
$this->maniaControl->configurator->showMenu($player, $this);
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-01-16 19:40:54 +01:00
|
|
|
* Apply the Array of new Server Settings
|
2014-01-02 23:49:21 +01:00
|
|
|
*
|
2014-07-25 15:17:36 +02:00
|
|
|
* @param ServerOptions $newServerOptions
|
2014-05-20 15:42:10 +02:00
|
|
|
* @param Player $player
|
2014-01-04 17:18:11 +01:00
|
|
|
* @return bool
|
2014-01-02 23:49:21 +01:00
|
|
|
*/
|
2014-07-25 15:17:36 +02:00
|
|
|
private function applyNewServerOptions(ServerOptions $newServerOptions, Player $player) {
|
2014-04-22 21:56:18 +02:00
|
|
|
try {
|
2014-07-25 15:17:36 +02:00
|
|
|
$this->maniaControl->client->setServerOptions($newServerOptions);
|
2014-07-24 23:13:30 +02:00
|
|
|
} catch (ServerOptionsException $exception) {
|
|
|
|
$this->maniaControl->chat->sendException($exception, $player);
|
2014-04-22 21:56:18 +02:00
|
|
|
return false;
|
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-25 15:17:36 +02:00
|
|
|
$this->saveServerOptions($newServerOptions, true);
|
2014-07-24 23:13:30 +02:00
|
|
|
|
|
|
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTINGS_CHANGED, array(self::CB_SERVERSETTINGS_CHANGED));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-24 23:13:30 +02:00
|
|
|
/**
|
|
|
|
* Save the given server options in the database
|
|
|
|
*
|
|
|
|
* @param ServerOptions $serverOptions
|
|
|
|
* @param bool $triggerCallbacks
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function saveServerOptions(ServerOptions $serverOptions, $triggerCallbacks = false) {
|
|
|
|
$mysqli = $this->maniaControl->database->mysqli;
|
2014-01-05 20:34:48 +01:00
|
|
|
$query = "INSERT INTO `" . self::TABLE_SERVER_SETTINGS . "` (
|
2014-01-05 14:41:19 +01:00
|
|
|
`serverIndex`,
|
2014-01-04 17:18:11 +01:00
|
|
|
`settingName`,
|
|
|
|
`settingValue`
|
|
|
|
) VALUES (
|
|
|
|
?, ?, ?
|
|
|
|
) ON DUPLICATE KEY UPDATE
|
|
|
|
`settingValue` = VALUES(`settingValue`);";
|
|
|
|
$statement = $mysqli->prepare($query);
|
2014-02-01 20:03:17 +01:00
|
|
|
if ($mysqli->error) {
|
2014-01-04 17:18:11 +01:00
|
|
|
trigger_error($mysqli->error);
|
|
|
|
return false;
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-24 23:13:30 +02:00
|
|
|
$settingName = null;
|
|
|
|
$settingValue = null;
|
|
|
|
$statement->bind_param('iss', $this->maniaControl->server->index, $settingName, $settingValue);
|
|
|
|
|
|
|
|
$settingsArray = $serverOptions->toArray();
|
|
|
|
foreach ($settingsArray as $settingName => $settingValue) {
|
|
|
|
if ($settingValue === null) {
|
2014-01-20 09:24:17 +01:00
|
|
|
continue;
|
|
|
|
}
|
2014-02-01 20:03:17 +01:00
|
|
|
|
2014-01-04 17:18:11 +01:00
|
|
|
$statement->execute();
|
2014-02-01 20:03:17 +01:00
|
|
|
if ($statement->error) {
|
2014-01-04 17:18:11 +01:00
|
|
|
trigger_error($statement->error);
|
|
|
|
$statement->close();
|
|
|
|
return false;
|
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-07-24 23:13:30 +02:00
|
|
|
if ($triggerCallbacks) {
|
|
|
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTING_CHANGED, array(self::CB_SERVERSETTING_CHANGED, $settingName, $settingValue));
|
|
|
|
}
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
2014-01-05 20:34:48 +01:00
|
|
|
|
2014-01-04 17:18:11 +01:00
|
|
|
$statement->close();
|
|
|
|
return true;
|
2014-01-02 23:49:21 +01:00
|
|
|
}
|
|
|
|
}
|