<?php

/**
 *
 * "3 last months Browsers stats" from Statcounter ( http://gs.statcounter.com/ )
 * Widget for Panic's Status Board
 * Developer: Christophe VERGNE
 *
 **/
header('Content-type: application/json');
// #Cache use (optionnal)
if (file_exists('./cacheClass.php')) {
    require_once './cacheClass.php';
    $oCache = new Caching();
    $fileCache = $oCache->getCache("_gs");
}
// #If no cache
if (!isset($fileCache) || !$fileCache) {
    // #Date range
    $gs_dateFrom = date('Y-m', strtotime('3 months ago'));
    $gs_dateTo = date('Y-m', strtotime('1 month ago'));
    // #"API" uri
    $gs_Uri = 'http://gs.statcounter.com/chart.php?bar=1&statType_hidden=browser_version_partially_combined&region_hidden=ww&granularity=monthly&statType=Browser%20Version%20(Partially%20Combined)&region=Worldwide&fromMonthYear=' . $gs_dateFrom . '&toMonthYear=' . $gs_dateTo;
    $result = array('graph' => array('title' => 'Browser Versions', 'type' => 'bar', 'yAxis' => array('units' => array('suffix' => '%'))));
    // #Data limit
    $limit = 5;
    if (isset($_GET['limit'])) {
        $limit = intval($_GET['limit']);
    }
    $current = 1;
    // #Parse data