mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 13:24:01 -07:00
Used datastore to show statistic for more performance (#1309)
* Used datastore to show statistic for more performance * Update admin_forums.php
This commit is contained in:
parent
f48e7121df
commit
6bf987edb0
4 changed files with 11 additions and 46 deletions
|
@ -472,6 +472,7 @@ if ($mode) {
|
|||
fix_orphan_sf();
|
||||
\TorrentPier\Legacy\Group::update_user_level('all');
|
||||
$datastore->update('cat_forums');
|
||||
$datastore->update('stats');
|
||||
CACHE('bb_cache')->rm();
|
||||
|
||||
bb_die($lang['FORUMS_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_FORUMADMIN'], '<a href="admin_forums.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
|
||||
require __DIR__ . '/pagestart.php';
|
||||
|
||||
// Statistics
|
||||
if (!$stats = $datastore->get('stats')) {
|
||||
$datastore->update('stats');
|
||||
$stats = $datastore->get('stats');
|
||||
}
|
||||
|
||||
// Generate relevant output
|
||||
if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
||||
$module = [];
|
||||
|
@ -71,9 +77,9 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
|||
]);
|
||||
|
||||
// Get forum statistics
|
||||
$total_posts = get_db_stat('postcount');
|
||||
$total_users = get_db_stat('usercount');
|
||||
$total_topics = get_db_stat('topiccount');
|
||||
$total_posts = $stats['postcount'];
|
||||
$total_topics = $stats['topiccount'];
|
||||
$total_users = $stats['usercount'];
|
||||
$start_date = bb_date($bb_cfg['board_startdate']);
|
||||
$boarddays = (TIMENOW - $bb_cfg['board_startdate']) / 86400;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ $row = DB()->fetch_row("SELECT COUNT(*) AS usercount FROM " . BB_USERS . " WHERE
|
|||
$data['usercount'] = commify($row['usercount']);
|
||||
|
||||
// newestuser
|
||||
$row = DB()->fetch_row("SELECT user_id, username, user_rank FROM " . BB_USERS . " WHERE user_active = 1 ORDER BY user_id DESC LIMIT 1");
|
||||
$row = DB()->fetch_row("SELECT user_id, username, user_rank FROM " . BB_USERS . " WHERE user_active = 1 AND user_id NOT IN(" . EXCLUDED_USERS . ") ORDER BY user_id DESC LIMIT 1");
|
||||
$data['newestuser'] = $row;
|
||||
|
||||
// post/topic count
|
||||
|
|
|
@ -932,48 +932,6 @@ function bb_update_config($params, $table = BB_CONFIG)
|
|||
bb_get_config($table, true, true);
|
||||
}
|
||||
|
||||
function get_db_stat($mode)
|
||||
{
|
||||
$sql = null;
|
||||
switch ($mode) {
|
||||
case 'usercount':
|
||||
$sql = "SELECT COUNT(user_id) AS total FROM " . BB_USERS;
|
||||
break;
|
||||
|
||||
case 'newestuser':
|
||||
$sql = "SELECT user_id, username FROM " . BB_USERS . " WHERE user_id <> " . GUEST_UID . " ORDER BY user_id DESC LIMIT 1";
|
||||
break;
|
||||
|
||||
case 'postcount':
|
||||
case 'topiccount':
|
||||
$sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total FROM " . BB_FORUMS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$row = DB()->sql_fetchrow($result);
|
||||
|
||||
switch ($mode) {
|
||||
case 'usercount':
|
||||
return $row['total'];
|
||||
break;
|
||||
case 'newestuser':
|
||||
return $row;
|
||||
break;
|
||||
case 'postcount':
|
||||
return $row['post_total'];
|
||||
break;
|
||||
case 'topiccount':
|
||||
return $row['topic_total'];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function clean_username($username)
|
||||
{
|
||||
$username = mb_substr(htmlspecialchars(str_replace("\'", "'", trim($username))), 0, 25, 'UTF-8');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue