/**
 * A helper function to call the stats API
 *
 * @param string $table Optional. Table for stats can be views, postviews, referrers, searchterms, clicks. Default is views.
 * @param string $end_data Optional. The last day of the desired time frame. Format is 'Y-m-d' (e.g. 2007-05-01) and default is UTC date.
 * @param int $num_days Optional. The length of the desired time frame. Default is 1. Maximum 90 days.
 * @param string $and Optional. Possibility to refine the query with additional AND condition. Usually unused.
 * @param int $limit Optional. The maximum number of records to return. Default is 100 (also the maximum).
 * @return array Fresh tasty data
 */
function _wpcom_vip_get_stats_result($table = 'views', $end_date = false, $num_days = 1, $and = '', $limit = 100)
{
    global $wpdb;
    $blog_id = $wpdb->blogid;
    // adjust parameters
    if (!in_array($table, array('views', 'postviews', 'authorviews', 'referrers', 'searchterms', 'clicks'))) {
        $table = 'views';
    }
    if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $end_date)) {
        $end_date = stats_today($blog_id);
    }
    if ($limit > 100) {
        $limit = 100;
    } else {
        $limit = (int) $limit;
    }
    if ($num_days > 90) {
        $num_days = 90;
    } else {
        $num_days = (int) $num_days;
    }
    $args = array($blog_id, $end_date, $num_days, $and, $limit);
    $result = array();
    if (is_callable("stats_get_{$table}")) {
        $result = call_user_func_array("stats_get_{$table}", $args);
    }
    return $result;
}
    exit;
}
if (isset($_GET["tabs"])) {
    tabs();
    exit;
}
if (isset($_GET["traffic-today"])) {
    traffic_today();
    exit;
}
if (isset($_GET["memory-today"])) {
    memory_today();
    exit;
}
if (isset($_GET["today"])) {
    stats_today();
    exit;
}
tabs_start();
function tabs()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $array["status"] = "{events}";
    //$array["today"]="{last_24h}";
    while (list($num, $ligne) = each($array)) {
        $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}=yes&servername={$_GET["servername"]}&group_id={$_REQUEST["group_id"]}\"><span>{$ligne}</span></a></li>\n");
    }
    echo "\n\t<div id=main_config_freewebstats style='width:100%;overflow:auto'>\n\t\t<ul>" . implode("\n", $html) . "</ul>\n\t</div>\n\t\t<script>\n\t\t  \$(document).ready(function() {\n\t\t\t\$(\"#main_config_freewebstats\").tabs();});\n\t\t</script>";
}
function tabs_start()