/** * Get some forum stats. * * @return array A map of forum stats. */ function ocf_get_forums_stats() { $out = array(); $out['num_topics'] = $GLOBALS['OCF_DRIVER']->get_topics(); $out['num_posts'] = $GLOBALS['OCF_DRIVER']->get_num_forum_posts(); $out['num_members'] = $GLOBALS['OCF_DRIVER']->get_members(); $temp = get_value_newer_than('ocf_newest_member_id', time() - 60 * 60 * 1); $out['newest_member_id'] = is_null($temp) ? NULL : intval($temp); if (!is_null($out['newest_member_id'])) { $out['newest_member_username'] = get_value_newer_than('ocf_newest_member_username', time() - 60 * 60 * 1); } else { $out['newest_member_username'] = NULL; } $out['newest_member_username'] = NULL; if (is_null($out['newest_member_username'])) { $newest_member = $GLOBALS['FORUM_DB']->query('SELECT m_username,id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_validated=1 AND id<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY m_join_time DESC', 1); // Only ordered by m_join_time and not double ordered with ID to make much faster in MySQL $out['newest_member_id'] = $newest_member[0]['id']; $out['newest_member_username'] = $newest_member[0]['m_username']; if (get_db_type() != 'xml') { set_value('ocf_newest_member_id', strval($out['newest_member_id'])); set_value('ocf_newest_member_username', $out['newest_member_username']); } } return $out; }
/** * Get the number of CEDI posts currently in the database. * * @return integer The number of posts in the CEDI database */ function get_num_cedi_posts() { $value = get_value_newer_than('num_seedy_posts', time() - 60 * 60 * 24); if (is_null($value)) { $_value = $GLOBALS['SITE_DB']->query_value_null_ok('seedy_posts', 'COUNT(*)'); if (!($_value > 0)) { $_value = 0; } $value = strval($_value); set_value('num_seedy_posts', $value); } return intval($value); }
/** * Get the number of users on the site in the last 5 minutes. The function also maintains the statistic via the sessions table. * * @return integer The number of users on the site */ function get_num_users_site() { global $NUM_USERS_SITE, $PEAK_USERS_EVER; $users_online_time_seconds = 60 * intval(get_option('users_online_time')); $NUM_USERS_SITE = get_value_newer_than('users_online', time() - $users_online_time_seconds / 2); if ($NUM_USERS_SITE === NULL) { $NUM_USERS_SITE = get_value('users_online'); $count = 0; get_online_members(false, NULL, $count); if (strval($count) != $NUM_USERS_SITE) { $NUM_USERS_SITE = strval($count); set_value('users_online', $NUM_USERS_SITE); } } if (intval($NUM_USERS_SITE) > intval(get_option('maximum_users')) && intval(get_option('maximum_users')) > 1 && get_page_name() != 'login' && !has_specific_permission(get_member(), 'access_overrun_site') && !running_script('cron_bridge')) { $GLOBALS['HTTP_STATUS_CODE'] = '503'; header('HTTP/1.0 503 Service Unavailable'); critical_error('BUSY', do_lang('TOO_MANY_USERS')); } if (addon_installed('stats')) { $PEAK_USERS_EVER = get_value_newer_than('user_peak', time() - $users_online_time_seconds * 10); if ($PEAK_USERS_EVER === NULL || $PEAK_USERS_EVER == '') { $_peak_users_user = $GLOBALS['SITE_DB']->query_value_null_ok('usersonline_track', 'MAX(peak)', NULL, '', true); $PEAK_USERS_EVER = $_peak_users_user === NULL ? $NUM_USERS_SITE : strval($_peak_users_user); set_value('user_peak', $PEAK_USERS_EVER); } if ($NUM_USERS_SITE > $PEAK_USERS_EVER) { // In case the record is beaten more than once within the same second $time = time(); $GLOBALS['SITE_DB']->query_delete('usersonline_track', array('date_and_time' => $time), '', 1, NULL, true); // New record $GLOBALS['SITE_DB']->query_insert('usersonline_track', array('date_and_time' => $time, 'peak' => intval($NUM_USERS_SITE)), false, true); } } return intval($NUM_USERS_SITE); }
/** * Get the total number of files downloaded since installation. * * @return integer The total number of files downloaded since installation */ function get_num_downloads_downloaded() { $value = intval(get_value_newer_than('num_downloads_downloaded', time() - 60 * 60 * 24)); if ($value == 0) { $value = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'SUM(num_downloads)', array('validated' => 1)); if (!(intval($value) > 0)) { $value = 0; } set_value('num_downloads_downloaded', strval($value)); } return $value; }
/** * Get the total posts ever made on the forum. * * @return integer The number of posts */ function get_num_forum_posts() { $value = intval(get_value_newer_than('ocf_post_count', time() - 60 * 60 * 3)); if ($value == 0) { $value = $this->connection->query_value('f_posts', 'COUNT(*)'); set_value('ocf_post_count', strval($value)); } return $value; }