mirror of
https://github.com/slawkens/myaac.git
synced 2025-05-01 19:59:21 +02:00
Move status config to settings
This commit is contained in:
parent
55a5ccdd1e
commit
a8a2c72381
14
config.php
14
config.php
@ -166,23 +166,9 @@ $config = array(
|
||||
// gifts/shop system
|
||||
'gifts_system' => false,
|
||||
|
||||
// support/system
|
||||
'bug_report' => true, // this configurable has no effect, its always enabled
|
||||
|
||||
// last kills
|
||||
'last_kills_limit' => 50, // max. number of deaths shown on the last kills page
|
||||
|
||||
// status, took automatically from config file if empty
|
||||
'status_enabled' => true, // you can disable status checking by settings this to "false"
|
||||
'status_ip' => '',
|
||||
'status_port' => '',
|
||||
'status_timeout' => 2.0, // how long to wait for the initial response from the server (default: 2 seconds)
|
||||
|
||||
// how often to connect to server and update status (default: every minute)
|
||||
// if your status timeout in config.lua is bigger, that it will be used instead
|
||||
// when server is offline, it will be checked every time web refreshes, ignoring this variable
|
||||
'status_interval' => 60,
|
||||
|
||||
// admin panel
|
||||
'admin_plugins_manage_enable' => 'yes', // you can disable possibility to upload and uninstall plugins, for security
|
||||
// enable support for plain php pages in admin panel, for security
|
||||
|
@ -426,7 +426,9 @@ class Settings implements ArrayAccess
|
||||
break;
|
||||
|
||||
case 'number':
|
||||
$ret['value'] = (int)$ret['value'];
|
||||
if (!isset($ret['step']) || (int)$ret['step'] == 1) {
|
||||
$ret['value'] = (int)$ret['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -57,7 +57,7 @@ class OTS_ServerInfo
|
||||
private function send(OTS_Buffer $packet)
|
||||
{
|
||||
// connects to server
|
||||
$socket = @fsockopen($this->server, $this->port, $error, $message, config('status_timeout'));
|
||||
$socket = @fsockopen($this->server, $this->port, $error, $message, setting('core.status_timeout'));
|
||||
|
||||
// if connected then checking statistics
|
||||
if($socket)
|
||||
|
@ -118,7 +118,7 @@ return [
|
||||
'desc' => 'Time To Live for Visitors Counter. In other words - how long user will be marked as online. In Minutes',
|
||||
'default' => 10,
|
||||
'show_if' => [
|
||||
'visitors_counter'=> '=', 'true'
|
||||
'visitors_counter', '=', 'true'
|
||||
]
|
||||
],
|
||||
'views_counter' => [
|
||||
@ -787,5 +787,60 @@ Sent by MyAAC,<br/>
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
],
|
||||
[
|
||||
'type' => 'category',
|
||||
'title' => 'Status',
|
||||
],
|
||||
[
|
||||
'type' => 'section',
|
||||
'title' => 'Server Status'
|
||||
],
|
||||
'status_enabled' => [
|
||||
'name' => 'Enable Server Status',
|
||||
'type' => 'boolean',
|
||||
'desc' => 'You can disable status checking here',
|
||||
'default' => true,
|
||||
],
|
||||
'status_ip' => [
|
||||
'name' => 'Status IP',
|
||||
'type' => 'text',
|
||||
'desc' => 'Leave empty to get automatically from config',
|
||||
'default' => '127.0.0.1',
|
||||
'show_if' => [
|
||||
'status_enabled', '=', 'true',
|
||||
]
|
||||
],
|
||||
'status_port' => [
|
||||
'name' => 'Status Port',
|
||||
'type' => 'number',
|
||||
'min' => 0,
|
||||
'desc' => 'Leave empty to get automatically from config',
|
||||
'default' => 7171,
|
||||
'show_if' => [
|
||||
'status_enabled', '=', 'true',
|
||||
]
|
||||
],
|
||||
'status_timeout' => [
|
||||
'name' => 'Status Timeout',
|
||||
'type' => 'number',
|
||||
'min' => 0,
|
||||
'max' => 10, // more than 10 seconds waiting makes no sense
|
||||
'step' => 0.1,
|
||||
'desc' => 'How long to wait for the initial response from the server',
|
||||
'default' => 2.0,
|
||||
'show_if' => [
|
||||
'status_enabled', '=', 'true',
|
||||
]
|
||||
],
|
||||
'status_interval' => [
|
||||
'name' => 'Status Interval',
|
||||
'type' => 'number',
|
||||
'min' => 0,
|
||||
'desc' => 'How often to connect to server and update status.<br/>If your status timeout in config.lua is bigger, that it will be used instead. When server is offline, it will be checked every time web refreshes, ignoring this variable',
|
||||
'default' => 60,
|
||||
'show_if' => [
|
||||
'status_enabled', '=', 'true',
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -17,7 +17,7 @@ $status['lastCheck'] = 0;
|
||||
$status['uptime'] = '0h 0m';
|
||||
$status['monsters'] = 0;
|
||||
|
||||
if(config('status_enabled') === false) {
|
||||
if(setting('core.status_enabled') === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -37,9 +37,10 @@ else if(isset($config['lua']['status_port'])) {
|
||||
}
|
||||
|
||||
// ip check
|
||||
if(isset($config['status_ip'][0]))
|
||||
$settingIP = setting('core.status_ip');
|
||||
if(isset($settingIP[0]))
|
||||
{
|
||||
$status_ip = $config['status_ip'];
|
||||
$status_ip = $settingIP;
|
||||
}
|
||||
elseif(!isset($status_ip[0])) // try localhost if no ip specified
|
||||
{
|
||||
@ -48,10 +49,11 @@ elseif(!isset($status_ip[0])) // try localhost if no ip specified
|
||||
|
||||
// port check
|
||||
$status_port = $config['lua']['statusPort'];
|
||||
if(isset($config['status_port'][0])) {
|
||||
$status_port = $config['status_port'];
|
||||
$settingPort = setting('core.status_port');
|
||||
if(isset($settingPort[0])) {
|
||||
$status_port = $settingPort;
|
||||
}
|
||||
elseif(!isset($status_port[0])) // try 7171 if no ip specified
|
||||
elseif(!isset($status_port[0])) // try 7171 if no port specified
|
||||
{
|
||||
$status_port = 7171;
|
||||
}
|
||||
@ -94,9 +96,9 @@ if(isset($config['lua']['statustimeout']))
|
||||
|
||||
// get status timeout from server config
|
||||
$status_timeout = eval('return ' . $config['lua']['statusTimeout'] . ';') / 1000 + 1;
|
||||
$status_interval = @$config['status_interval'];
|
||||
if($status_interval && $status_timeout < $config['status_interval']) {
|
||||
$status_timeout = $config['status_interval'];
|
||||
$status_interval = setting('core.status_interval');
|
||||
if($status_interval && $status_timeout < $status_interval) {
|
||||
$status_timeout = $status_interval;
|
||||
}
|
||||
|
||||
if($status['lastCheck'] + $status_timeout < time()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user