Exemple #1
0
function fs_ajax_send_update(&$response)
{
    if (!isset($_POST['update'])) {
        return;
    }
    $update_blocks = explode(';', $_POST['update']);
    // if we have no more blocks return.
    if (count($update_blocks) == 0) {
        return;
    }
    // pop the first block.
    $update = array_shift($update_blocks);
    if (count($update_blocks) > 0) {
        // push the remaining items to the response, so the client will be able to send antoher request with the rest.
        $response['send_request'] = "action=updateFields&update=" . implode(";", $update_blocks);
    }
    $updates = explode(',', $update);
    foreach ($updates as $update) {
        switch ($update) {
            case 'popular_pages':
                $response['fields'][$update] = addslashes(fs_get_popular_pages_tree());
                break;
            case 'records_table':
                $response['fields'][$update] = fs_get_records_table();
                break;
            case 'countries_list':
                $response['fields'][$update] = fs_get_countries_list();
                break;
            case 'fs_recent_referers':
                $response['fields'][$update] = addslashes(fs_get_recent_referers_tree());
                $response['type'][$update] = 'tree';
                break;
            case 'fs_browsers_tree':
                $response['fields'][$update] = fs_get_browsers_tree();
                $response['type'][$update] = 'tree';
                break;
            case 'fs_os_tree':
                $response['fields'][$update] = fs_get_os_tree();
                $response['type'][$update] = 'tree';
                break;
            case 'fs_search_terms':
                $response['fields'][$update] = fs_get_search_terms_tree();
                $response['type'][$update] = 'tree';
                break;
            case 'botlist_placeholder':
                $response['fields']['botlist_placeholder'] = addslashes(fs_get_bot_list());
                break;
            case 'num_excluded':
                $response['fields']['num_excluded'] = fs_get_num_excluded();
                break;
            case 'stats_total_count':
                $response['fields']['stats_total_count'] = fs_get_hit_count();
                break;
            case 'stats_total_unique':
                $response['fields']['stats_total_unique'] = fs_get_unique_hit_count();
                break;
            case 'stats_total_count_last_day':
                $response['fields']['stats_total_count_last_day'] = fs_get_hit_count(1);
                break;
            case 'stats_total_unique_last_day':
                $response['fields']['stats_total_unique_last_day'] = fs_get_unique_hit_count(1);
                break;
            case 'fs_sites_table':
                $response['fields']['fs_sites_table'] = fs_get_sites_manage_table();
                break;
            case 'fs_users_table':
                $response['fields']['fs_users_table'] = fs_get_users_manage_table();
                break;
            case 'sites_filter_span':
                $response['fields']['sites_filter_span'] = fs_get_sites_list();
                break;
            case 'fs_archive_status':
                $response['fields']['fs_archive_status'] = sprintf(fs_r("%s days can be compacted, database size %s"), fs_get_num_old_days(), sprintf("%.1f MB", fs_get_database_size() / (1024 * 1024)));
                break;
            default:
                ajax_error($response, sprintf("AJAX:" . fs_r('Unkown field: %s'), $update));
        }
    }
}
Exemple #2
0
<button class="button" id="refresh_button"
	onclick="updateAllStats();toggleAutoRefresh()">
<?php 
fs_e('Refresh statistics');
?>
</button>
<?php 
fs_cfg_button('refresh_button_config');
?>
	
	<?php 
if (fs_is_admin()) {
    ?>
	<span id="sites_filter_span">
	<?php 
    echo fs_get_sites_list();
    ?>
	</span>
	<?php 
}
?>

	<br/>
	<span id="refresh_button_config" class="normal_font hidden">
		<?php 
$auto_refresh_enabled = fs_get_option('firestats_auto_refresh_enabled', 'true');
$auto_refresh_interval = fs_get_option('firestats_auto_refresh_interval', '5');
$auto_refresh_checked = $auto_refresh_enabled == 'true' ? "checked=\"checked\"" : "";
?>

		<input type="checkbox"