Example #1
0
<?php

include dirname(__FILE__) . '/../../../../wp-config.php';
include dirname(__FILE__) . "/../lib/charts/charts.php";
$csv = false;
if (isset($_GET['csv'])) {
    $csv = true;
}
if (current_user_can('administrator')) {
    $chart = array();
    if ($_GET['type'] == 'percent') {
        $files = DH_Version::get_totals_by_hole(intval($_GET['hole']));
        if (count($files) > 0) {
            // Calculate total
            $total = $largest = 0;
            foreach ($files as $file) {
                $total += $file->hits;
                $largest = max($largest, $file->hits);
            }
            $merged = array();
            foreach ($files as $pos => $file) {
                // Remove any files that have no hits
                if ($file->hits == 0) {
                    unset($files[$pos]);
                } else {
                    if ($file->hits / $total <= 0.03) {
                        $merged[] = $file;
                        $total -= $file->hits;
                        unset($files[$pos]);
                    }
                }