mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 01:34:55 +02:00
feat: replace POT Query Builder to Eloquent ORM (#230)
* wip * wip * wip * wip * wip * fix: reusing pdo connection from pot * wip * wip * wip * wip * move files In future, all classes will be in src/ folder * Replace namespace name, for future * Remove duplicated exception * Fix towns from db * Fix spells page * Add default FAQ question + FAQ model * feat: reset colors in menus * Add confirm + save button at the top (menus) * Do not insert duplicated FAQ on install * Refactor install menus * Fix changelogs showing * Fix menu update, only with specified template name * Fix account create -> missing compat * Fix bans_per_page * banned_by is player_id. type = 2 is namelock in tfs 0.3 * Add getPlayerNameById, fix getPlayerNameByAccount * Change link name * Order by lastlogin * fix: query optimize * wip * wip * wip * wip * wip * wip * wip * Refactor notepad.php, class was useless * This is showing error, if the updated rows = 0 * Fix success & error class (bootstrap) * Uncomment require migrate.php * Some distro have owner_id * Update Player.php --------- Co-authored-by: slawkens <slawkens@gmail.com>
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Config;
|
||||
use MyAAC\Models\PlayerOnline;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$status = array();
|
||||
@@ -74,20 +78,15 @@ if($cache->enabled())
|
||||
|
||||
if($fetch_from_db)
|
||||
{
|
||||
// get info from db
|
||||
/**
|
||||
* @var OTS_DB_MySQL $db
|
||||
*/
|
||||
$status_query = $db->query('SELECT `name`, `value` FROM `' . TABLE_PREFIX . 'config` WHERE ' . $db->fieldName('name') . ' LIKE "%status%"');
|
||||
if($status_query->rowCount() <= 0) // empty, just insert it
|
||||
{
|
||||
foreach($status as $key => $value)
|
||||
$status_query = Config::where('name', 'LIKE', '%status%')->get();
|
||||
if (!$status_query || !$status_query->count()) {
|
||||
foreach($status as $key => $value) {
|
||||
registerDatabaseConfig('status_' . $key, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($status_query as $tmp)
|
||||
$status[str_replace('status_', '', $tmp['name'])] = $tmp['value'];
|
||||
}
|
||||
} else {
|
||||
foreach($status_query as $tmp) {
|
||||
$status[str_replace('status_', '', $tmp->name)] = $tmp->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,19 +127,13 @@ function updateStatus() {
|
||||
// for status afk thing
|
||||
if($config['online_afk'])
|
||||
{
|
||||
$status['playersTotal'] = 0;
|
||||
// get amount of players that are currently logged in-game, including disconnected clients (exited)
|
||||
if($db->hasTable('players_online')) { // tfs 1.x
|
||||
$query = $db->query('SELECT COUNT(`player_id`) AS `playersTotal` FROM `players_online`;');
|
||||
$status['playersTotal'] = PlayerOnline::count();
|
||||
}
|
||||
else {
|
||||
$query = $db->query('SELECT COUNT(`id`) AS `playersTotal` FROM `players` WHERE `online` > 0');
|
||||
}
|
||||
|
||||
$status['playersTotal'] = 0;
|
||||
if($query->rowCount() > 0)
|
||||
{
|
||||
$query = $query->fetch();
|
||||
$status['playersTotal'] = $query['playersTotal'];
|
||||
$status['playersTotal'] = Player::online()->count();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user