Beispiel #1
0
function fs_api_get_page_views($days_ago = NULL, $site_id = true, $url = null)
{
    require_once dirname(__FILE__) . '/db-sql.php';
    $url_id = null;
    if ($url) {
        $url_id = fs_get_url_id($url);
        if ($url_id === null) {
            return 0;
        }
    }
    return fs_get_hit_count($days_ago, $site_id, $url_id);
}
Beispiel #2
0
function fs_get_sites_manage_table()
{
    $sites = fs_get_sites();
    $res = "<table>";
    $idH = fs_r('ID');
    $nameH = fs_r('Name');
    $typeH = fs_r("Type");
    $views = fs_r("Page views");
    $res .= "<tr>\n\t\t<th style='width:30px'>{$idH}</th>\n\t\t<th style='width:280px'>{$nameH}</th>\n\t\t<th style='width:80px'>{$typeH}</th>\n\t\t<th style='width:60px'>{$views}</th>\n\t\t<th style='width:80px'></th>\n\t\t</tr>";
    if (count($sites) > 0) {
        foreach ($sites as $site) {
            $id = $site['id'];
            $hits = fs_get_hit_count(null, $id);
            $name = $site['name'];
            $type = $site['type'];
            $typeStr = fs_get_site_type_str($type);
            $tip = fs_r('How to integrate with this site');
            $text = "<tr id='site_row_{$id}'>\n\t\t\t\t<td id='site_id_{$id}'>{$id}</td>\n\t\t\t\t<td id='site_name_{$id}'>{$name}</td>\n\t\t\t\t<td id='site_type_{$id}'>{$typeStr}</td>\n\t\t\t\t<td id='site_hits_{$id}'>{$hits}</td>\n\t\t\t\t<td>\n\t\t\t\t<input type='image' class='img_btn' src='" . fs_url("img/edit.png") . "' onclick='FS.editSiteDialog(\"{$id}\")'/>\n\t\t\t\t<input type='image' class='img_btn' src='" . fs_url("img/delete.png") . "' onclick='FS.deleteSiteDialog(\"{$id}\")'/>\n\t\t\t\t<input type='image' class='img_btn' title='{$tip}' src='" . fs_url("img/help.blue.png") . "' onclick='FS.activationHelp({$type},{$id})'/>\n\t\t\t\t</td>\n\t\t\t\t</tr>";
            $res .= "{$text}\n";
        }
    }
    $orphans = fs_get_orphan_site_ids();
    if ($orphans != false && count($orphans) > 0) {
        foreach ($orphans as $site) {
            $id = $site['id'];
            $hits = fs_get_hit_count(null, $id);
            $name = fs_r("Orphaned hits");
            $text = "<tr id='site_row_{$id}'>\n\t\t\t\t<td id='site_id_{$id}'>{$id}</td>\n\t\t\t\t<td id='site_name_{$id}'>{$name}</td>\n\t\t\t\t<td id='site_type_{$id}'></td>\n\t\t\t\t<td id='site_hits_{$id}'>{$hits}</td>\n\t\t\t\t<td></td>\n\t\t\t\t</tr>";
            $res .= "{$text}\n";
        }
    }
    $add_new = fs_r('Add a new site');
    $res .= "<tr><td colspan='5'>\n\t\t<input type='image' class='img_btn' src='" . fs_url("img/add.png") . "' onclick='FS.newSiteDialog()'/>  {$add_new}\n\t\t</td></tr></table>";
    return $res;
}
Beispiel #3
0
function fs_echo_footer()
{
    $FS_PATH = fs_get_firestats_path();
    if (!$FS_PATH) {
        return;
    }
    require_once $FS_PATH . '/php/db-sql.php';
    $stats = get_option('firestats_show_footer_stats') == 'true';
    if ($stats) {
        $count = fs_get_hit_count();
        $unique = fs_get_unique_hit_count();
        $last_24h_count = fs_get_hit_count(1);
        $last_24h_unique = fs_get_unique_hit_count(1);
        echo $count . ' ' . fs_r('pages viewed') . ", {$last_24h_count} " . fs_r('today') . "<br/>";
        echo $unique . ' ' . fs_r('visits') . ", {$last_24h_unique} " . fs_r('today') . "<br/>";
    }
    echo fs_get_powered_by('fs_powered_by');
}
Beispiel #4
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));
        }
    }
}