mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-29 18:59:21 +02:00
serverinfo cleanup, fix cache, query optimizations
This commit is contained in:
parent
8f5487db2b
commit
0e941b2c1e
@ -1226,19 +1226,8 @@ function user_create_character($character_data) {
|
|||||||
|
|
||||||
// Returns counted value of all players online
|
// Returns counted value of all players online
|
||||||
function user_count_online() {
|
function user_count_online() {
|
||||||
if (config('ServerEngine') == 'TFS_10') {
|
$online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
|
||||||
$online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
|
return ($online !== false) ? $online['value'] : 0;
|
||||||
return ($online !== false) ? $online['value'] : 0;
|
|
||||||
} else {
|
|
||||||
$data = mysql_select_single("SELECT COUNT(`id`) AS `count` from `players` WHERE `online` = 1;");
|
|
||||||
return ($data !== false) ? $data['count'] : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns counted value of all accounts.
|
|
||||||
function user_count_accounts() {
|
|
||||||
$result = mysql_select_single("SELECT COUNT(`id`) AS `id` from `accounts`;");
|
|
||||||
return ($result !== false) ? $result['id'] : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* user_character_data (fetches whatever data you want from players table)!
|
/* user_character_data (fetches whatever data you want from players table)!
|
||||||
|
@ -1,34 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
$cache = new Cache('engine/cache/asideServerInfo');
|
||||||
|
if ($cache->hasExpired()) {
|
||||||
|
$asideServerInfo = mysql_select_single("
|
||||||
|
SELECT
|
||||||
|
(SELECT COUNT(`id`) FROM `accounts`) as `accounts`,
|
||||||
|
(SELECT COUNT(`id`) FROM `players`) as `players`,
|
||||||
|
(SELECT COUNT(`player_id`) FROM `players_online`) as `online`
|
||||||
|
");
|
||||||
|
$cache->setContent($asideServerInfo);
|
||||||
|
$cache->save();
|
||||||
|
} else {
|
||||||
|
$asideServerInfo = $cache->load();
|
||||||
|
}
|
||||||
|
?>
|
||||||
<div class="well widget">
|
<div class="well widget">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
Server Information
|
Server Information
|
||||||
</div>
|
</div>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<li><a href="onlinelist.php">Players online: <?php echo $asideServerInfo['online']; ?></a></li>
|
||||||
$status = true;
|
<li>Registered accounts: <?php echo $asideServerInfo['accounts'];?></li>
|
||||||
if ($config['status']['status_check']) {
|
<li>Registered players: <?php echo $asideServerInfo['players'];?></li>
|
||||||
@$sock = fsockopen ($config['status']['status_ip'], $config['status']['status_port'], $errno, $errstr, 1);
|
|
||||||
if(!$sock) {
|
|
||||||
echo "<span style='color:red;font-weight:bold;'><center>Server Offline!</center></span><br/>";
|
|
||||||
$status = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$info = chr(6).chr(0).chr(255).chr(255).'info';
|
|
||||||
fwrite($sock, $info);
|
|
||||||
$data='';
|
|
||||||
while (!feof($sock))$data .= fgets($sock, 1024);
|
|
||||||
fclose($sock);
|
|
||||||
echo "<span style='color:green;font-weight:bold;'><center>Server Online!</center></span><br />";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($status) {
|
|
||||||
?>
|
|
||||||
<li><a href="onlinelist.php">Players online:
|
|
||||||
<?php echo user_count_online(); ?></a></li>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<li>Registered accounts: <?php echo user_count_accounts();?></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -27,6 +27,7 @@ function toYesNo($bool) {
|
|||||||
}
|
}
|
||||||
// Loading stage list
|
// Loading stage list
|
||||||
$cache = new Cache('engine/cache/stages');
|
$cache = new Cache('engine/cache/stages');
|
||||||
|
$cache->useMemory(false);
|
||||||
if (user_logged_in() && is_admin($user_data)) {
|
if (user_logged_in() && is_admin($user_data)) {
|
||||||
if (isset($_GET['loadStages'])) {
|
if (isset($_GET['loadStages'])) {
|
||||||
echo "<p><strong>Logged in as admin, loading engine/XML/stages.xml file and updating cache.</strong></p>";
|
echo "<p><strong>Logged in as admin, loading engine/XML/stages.xml file and updating cache.</strong></p>";
|
||||||
@ -35,34 +36,18 @@ if (user_logged_in() && is_admin($user_data)) {
|
|||||||
if ($stagesXML !== false) {
|
if ($stagesXML !== false) {
|
||||||
$stagesData = array();
|
$stagesData = array();
|
||||||
// Load config (stages enabled or disabled)
|
// Load config (stages enabled or disabled)
|
||||||
if ($config['ServerEngine'] == 'TFS_10')
|
foreach ($stagesXML->config->attributes() as $name => $value)
|
||||||
foreach ($stagesXML->config->attributes() as $name => $value)
|
$stagesData["$name"] = "$value";
|
||||||
$stagesData["$name"] = "$value";
|
|
||||||
// Load stage levels
|
// Load stage levels
|
||||||
// Each stage XML object
|
// Each stage XML object
|
||||||
if ($config['ServerEngine'] == 'TFS_10') {
|
foreach ($stagesXML->stage as $stage) {
|
||||||
foreach ($stagesXML->stage as $stage) {
|
$rowData = array();
|
||||||
$rowData = array();
|
// Each attribute name and values on current stage object
|
||||||
// Each attribute name and values on current stage object
|
foreach ($stage->attributes() as $name => $value) {
|
||||||
foreach ($stage->attributes() as $name => $value) {
|
$rowData["$name"] = "$value";
|
||||||
$rowData["$name"] = "$value";
|
|
||||||
}
|
|
||||||
// Populate XML assoc array
|
|
||||||
$stagesData['stages'][] = $rowData;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TFS 0.3/4
|
|
||||||
foreach ($stagesXML->world as $world) {
|
|
||||||
foreach ($world->stage as $stage) {
|
|
||||||
$rowData = array();
|
|
||||||
// Each attribute name and values on current stage object
|
|
||||||
foreach ($stage->attributes() as $name => $value) {
|
|
||||||
$rowData["$name"] = "$value";
|
|
||||||
}
|
|
||||||
// Populate XML assoc array
|
|
||||||
$stagesData['stages'][] = $rowData;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// Populate XML assoc array
|
||||||
|
$stagesData['stages'][] = $rowData;
|
||||||
}
|
}
|
||||||
$cache->setContent($stagesData);
|
$cache->setContent($stagesData);
|
||||||
$cache->save();
|
$cache->save();
|
||||||
@ -83,6 +68,7 @@ if (user_logged_in() && is_admin($user_data)) {
|
|||||||
|
|
||||||
// Loading config.lua
|
// Loading config.lua
|
||||||
$cache = new Cache('engine/cache/luaconfig');
|
$cache = new Cache('engine/cache/luaconfig');
|
||||||
|
$cache->useMemory(false);
|
||||||
if (user_logged_in() && is_admin($user_data)) {
|
if (user_logged_in() && is_admin($user_data)) {
|
||||||
if (isset($_POST['loadConfig']) && isset($_POST['configData'])) {
|
if (isset($_POST['loadConfig']) && isset($_POST['configData'])) {
|
||||||
// Whitelist for values we are interested in
|
// Whitelist for values we are interested in
|
||||||
@ -120,19 +106,6 @@ if (user_logged_in() && is_admin($user_data)) {
|
|||||||
'staminaSystem',
|
'staminaSystem',
|
||||||
'experienceStages'
|
'experienceStages'
|
||||||
);
|
);
|
||||||
// TFS 0.3/4 compatibility, convert config value names to TFS 1.0 values
|
|
||||||
$tfs03to10 = array(
|
|
||||||
// TFS 0.3/4 TFS 1.0
|
|
||||||
'rateExperience' => 'rateExp',
|
|
||||||
'loginPort' => 'loginProtocolPort',
|
|
||||||
'rateExperienceFromPlayers' => 'experienceByKillingPlayers',
|
|
||||||
'dailyFragsToRedSkull' => 'killsToRedSkull',
|
|
||||||
'dailyFragsToBlackSkull' => 'killsToBlackSkull',
|
|
||||||
'removeRuneCharges' => 'removeChargesFromRunes',
|
|
||||||
'stairhopDelay' => 'stairJumpExhaustion',
|
|
||||||
'housePriceEachSquare' => 'housePriceEachSQM',
|
|
||||||
'idleKickTime' => 'kickIdlePlayerAfterMinutes',
|
|
||||||
);
|
|
||||||
// This will be the populated array with filtered relevant data
|
// This will be the populated array with filtered relevant data
|
||||||
$luaConfig = array();
|
$luaConfig = array();
|
||||||
|
|
||||||
@ -168,13 +141,7 @@ if (user_logged_in() && is_admin($user_data)) {
|
|||||||
// Remove unnecessary whitespace
|
// Remove unnecessary whitespace
|
||||||
$data[0] = trim($data[0]);
|
$data[0] = trim($data[0]);
|
||||||
$data[1] = trim($data[1]);
|
$data[1] = trim($data[1]);
|
||||||
// TFS 0.3/4 compatibility
|
|
||||||
if (isset($tfs03to10[$data[0]])) {
|
|
||||||
$data[0] = $tfs03to10[$data[0]];
|
|
||||||
if (isset($tfs03to10[$data[1]])) {
|
|
||||||
$data[1] = $tfs03to10[$data[1]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (in_array($data[0], $whitelist)) {
|
if (in_array($data[0], $whitelist)) {
|
||||||
// Type cast: boolean
|
// Type cast: boolean
|
||||||
if (in_array(strtolower($data[1]), array('true', 'false'))) {
|
if (in_array(strtolower($data[1]), array('true', 'false'))) {
|
||||||
@ -227,7 +194,12 @@ $stages = false;
|
|||||||
<h1>Server Information</h1>
|
<h1>Server Information</h1>
|
||||||
<p>Here you will find all basic information about <b><?php echo $config['site_title']; ?></b></p>
|
<p>Here you will find all basic information about <b><?php echo $config['site_title']; ?></b></p>
|
||||||
|
|
||||||
<?php if (($stagesData && isset($stagesData['enabled']) && $stagesData['enabled']) || (isset($luaConfig['experienceStages']) && $luaConfig['experienceStages'] === true)): $stages = true; ?>
|
<?php
|
||||||
|
if (
|
||||||
|
($stagesData && isset($stagesData['enabled']) && $stagesData['enabled'])
|
||||||
|
|| (isset($luaConfig['experienceStages']) && $luaConfig['experienceStages'] === true)
|
||||||
|
):
|
||||||
|
$stages = true; ?>
|
||||||
<h2>Server rates</h2>
|
<h2>Server rates</h2>
|
||||||
<table class="table tbl-hover">
|
<table class="table tbl-hover">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user