Ejemplo n.º 1
0
$time_end = $date->format("U");
$day_end = $date->format("Y-m-d");
$date->modify("-30 days");
$date->setTime(0, 0, 0);
$time_start = $date->format("U");
$stats = array();
while (true) {
    $day = $date->format("Y-m-d");
    $stats[$day] = 0;
    $date->modify("+1 day");
    if ($day == $day_end) {
        break;
    }
}
// hent statistikk
$result = \Kofradia\DB::get()->query("\n\tSELECT DATE(FROM_UNIXTIME(poker_time_start)) AS day, SUM(CONVERT(poker_prize - poker_cash, SIGNED) * IF((poker_winner = 1 AND poker_starter_up_id = up_id) OR (poker_winner = 2 AND poker_challenger_up_id = up_id), 1, -1)) sum_result\n\tFROM poker, users_players\n\tWHERE poker_time_start >= {$time_start} AND poker_time_start <= {$time_end} AND up_u_id = {$u_id} AND (up_id = poker_starter_up_id OR up_id = poker_challenger_up_id) AND poker_state = 4\n\tGROUP BY DATE(FROM_UNIXTIME(poker_time_start))");
while ($row = $result->fetch()) {
    $stats[$row['day']] = (double) $row['sum_result'];
}
$ofc = new OFC();
$ofc->title(new OFC_Title("Pokerstatistikk for {$up_name} siste 30 dager"));
$bar = new OFC_Charts_Area();
$bar->text("Resultat av poker");
$bar->dot_style()->type("solid-dot")->dot_size(3)->halo_size(2)->tip("#x_label#<br>#val# kr");
$bar->values(array_values($stats));
$bar->colour(OFC_Colours::$colours[0]);
$ofc->add_element($bar);
$ofc->axis_x()->label()->steps(2)->rotate(330)->labels(array_keys($stats));
$ofc->axis_y()->set_numbers(min(0, min($stats)), max($stats));
$ofc->dark_colors();
echo $ofc;
Ejemplo n.º 2
0
ajax::require_user();
global $_base;
// hent stats
$result = \Kofradia\DB::get()->query("SELECT name, extra, value, time FROM sitestats");
$sitestats = array();
$max = 0;
while ($row = $result->fetch()) {
    $sitestats[$row['name']][$row['extra']] = (int) $row['value'];
    $max = max($max, $row['value']);
}
$ofc = new OFC();
$c = new OFC_Colours();
$ofc->title(new OFC_Title("Rekord for antall pålogget"));
$ofc->tooltip()->title("font-size: 13px;font-weight:bold");
$info = array("max_online_900" => "15 minutter", "max_online_300" => "5 minutter", "max_online_60" => "1 minutt", "max_online_30" => "30 sekunder");
foreach ($info as $key => $title) {
    $bar = new OFC_Charts_Area();
    $bar->dot_style()->type("solid-dot")->dot_size(3)->halo_size(2)->tip("Rekord for #x_label#:<br>#val# i løpet av {$title}");
    $bar->text($title);
    $bar->values(array_values($sitestats[$key]));
    $bar->colour($c->pick());
    $ofc->add_element($bar);
}
$x_label = array();
foreach (array_keys($sitestats['max_online_60']) as $val) {
    $x_label[] = "{$val}:00 - " . ($val + 1) . ":00";
}
$ofc->axis_x()->label()->rotate(340)->labels($x_label)->steps(2);
$ofc->axis_y()->set_numbers(0, $max);
$ofc->dark_colors();
$ofc->dump();
Ejemplo n.º 3
0
$stats_redir = array();
$x = array();
for ($i = 1; $i <= $days; $i++) {
    $stats[$i] = 0;
    $stats_redir[$i] = 0;
    $x[] = "{$i}. " . $month;
}
// hent dagstatistikk
$result = \Kofradia\DB::get()->query("SELECT DAY(FROM_UNIXTIME(uhi_secs_hour)) AS day, SUM(uhi_hits) sum_hits, SUM(uhi_hits_redirect) sum_hits_redirect FROM users_hits, users_players WHERE up_u_id = {$u_id} AND up_id = uhi_up_id AND uhi_secs_hour >= {$time_from} AND uhi_secs_hour <= {$time_to} GROUP BY DAY(FROM_UNIXTIME(uhi_secs_hour))");
while ($row = $result->fetch()) {
    $stats[$row['day']] = (int) $row['sum_hits'];
    $stats_redir[$row['day']] = (int) $row['sum_hits_redirect'];
}
$ofc = new OFC();
$ofc->title(new OFC_Title("Sidevisninger for {$up_name} - " . $date->format(date::FORMAT_MONTH) . " " . $date->format("Y")));
$bar = new OFC_Charts_Area();
$bar->text("Antall visninger");
$bar->dot_style()->type("solid-dot")->dot_size(3)->halo_size(2)->tip("#x_label#<br>#val# visninger");
$bar->values(array_values($stats));
$bar->colour(OFC_Colours::$colours[0]);
$ofc->add_element($bar);
$bar = new OFC_Charts_Area();
$bar->text("Antall videresendinger");
$bar->dot_style()->type("solid-dot")->dot_size(3)->halo_size(2)->tip("#x_label#<br>#val# videresendinger");
$bar->values(array_values($stats_redir));
$bar->colour(OFC_Colours::$colours[1]);
$ofc->add_element($bar);
$ofc->axis_x()->label()->steps(2)->rotate(330)->labels($x);
$ofc->axis_y()->set_numbers(0, max(max($stats), max($stats_redir)));
$ofc->dark_colors();
echo $ofc;
Ejemplo n.º 4
0
    /** Vis oversikt over statistikk */
    protected static function show_stats()
    {
        // hent litt statistikk
        $result = \Kofradia\DB::get()->query("SELECT COUNT(su_id) FROM support");
        $totalt = $result->fetchColumn(0);
        // hent spillere med status..
        $result = \Kofradia\DB::get()->query("SELECT up_id, up_name, up_access_level, up_last_online FROM users_players WHERE up_access_level > 1 ORDER BY up_name");
        $players = array();
        $last_online = array();
        while ($row = $result->fetch()) {
            if ($row['up_access_level'] == 4) {
                $level = 3;
            } elseif ($row['up_access_level'] == 6) {
                $level = 3;
            } elseif ($row['up_access_level'] == 8) {
                $level = 7;
            } else {
                $level = $row['up_access_level'];
            }
            $players[$level][] = $row;
            $last_online[$row['up_id']] = $row['up_last_online'];
        }
        // hent antall besvarelser per bruker
        $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT sum_up_id, COUNT(sum_id) num_sum, MAX(sum_time) max_sum_time, m.up_last_online, m.up_access_level\n\t\t\tFROM support\n\t\t\t\tJOIN support_messages ON sum_su_id = su_id\n\t\t\t\tJOIN users_players s ON s.up_id = su_up_id\n\t\t\t\tJOIN users_players m ON m.up_id = sum_up_id AND m.up_u_id != s.up_u_id\n\t\t\tGROUP BY sum_up_id");
        $reply_users = array();
        while ($row = $result->fetch()) {
            if ($row['max_sum_time'] < time() - 2592000 && ($row['up_access_level'] == 0 || $row['up_access_level'] == 1)) {
                continue;
            }
            $reply_users[$row['sum_up_id']] = $row['num_sum'];
            $last_online[$row['sum_up_id']] = $row['up_last_online'];
        }
        // vis oversikt
        echo '
<table class="table center" style="width: 400px">
	<thead>
		<tr>
			<th colspan="3">Besvarte henvendelser</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td colspan="2">Antall henvendelser totalt</td>
			<td>' . game::format_number($totalt) . ' stk</td>
		</tr>
		<tr>
			<th colspan="3">Administratorer</th>
		</tr>' . self::show_stats_users($players, 7, $reply_users, $last_online) . '
		<tr>
			<th colspan="3">Seniormoderatorer</th>
		</tr>' . self::show_stats_users($players, 11, $reply_users, $last_online) . '
		<tr>
			<th colspan="3">Moderatorer</th>
		</tr>' . self::show_stats_users($players, 5, $reply_users, $last_online) . '
		<tr>
			<th colspan="3">Forummoderatorer</th>
		</tr>' . self::show_stats_users($players, 3, $reply_users, $last_online);
        // noen andre folk?
        if (count($reply_users) > 0) {
            echo '
		<tr>
			<th colspan="3">Andre brukere</th>
		</tr>';
            $i = 0;
            foreach ($reply_users as $player => $ant) {
                echo '
		<tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '>
			<td><user id="' . $player . '" /></td>
			<td class="r">' . game::format_number($ant) . '</td>
			<td class="r">' . game::timespan($last_online[$player], game::TIME_ABS) . '</td>
		</tr>';
            }
        }
        echo '
	</tbody>
</table>';
        // statistikk for de siste 30 ukene
        $uker = 30;
        $limit = 7 * $uker;
        $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT num_su, num_sum, date_sum\n\t\t\tFROM\n\t\t\t\t(SELECT COUNT(sum_id) num_sum, DATE(FROM_UNIXTIME(sum_time)) date_sum\n\t\t\t\t\tFROM support_messages\n\t\t\t\t\tGROUP BY DATE(FROM_UNIXTIME(sum_time))\n\t\t\t\t\tORDER BY date_sum DESC\n\t\t\t\t\tLIMIT {$limit}) ref_sum\n\t\t\t\tLEFT JOIN\n\t\t\t\t(SELECT COUNT(su_id) num_su, DATE(FROM_UNIXTIME(su_time)) date_su\n\t\t\t\t\tFROM support\n\t\t\t\t\tGROUP BY DATE(FROM_UNIXTIME(su_time))\n\t\t\t\t\tORDER BY date_su DESC\n\t\t\t\t\tLIMIT {$limit}) ref_su ON date_sum = date_su\n\t\t\tORDER BY date_sum DESC\n\t\t\tLIMIT {$limit}");
        $data = array();
        $d = ess::$b->date->get();
        for ($i = 0; $i < $uker; $i++) {
            $w = $d->format("o-W");
            $data['labels'][$w] = $w;
            $data['sum'][$w] = 0;
            $data['su'][$w] = 0;
            $d->modify("-1 week");
        }
        while ($row = $result->fetch()) {
            $w = ess::$b->date->parse($row['date_sum'])->format("o-W");
            if (!isset($data['labels'][$w])) {
                continue;
            }
            $data['sum'][$w] += (int) $row['num_sum'];
            $data['su'][$w] += (int) $row['num_su'];
        }
        // reverser så nyeste kommer sist
        $data['labels'] = array_reverse($data['labels']);
        $data['sum'] = array_reverse($data['sum']);
        $data['su'] = array_reverse($data['su']);
        $ofc = new OFC();
        $bar = new OFC_Charts_Area();
        $bar->text("Antall meldinger");
        $bar->dot_style()->type("solid-dot")->dot_size(3)->halo_size(2)->tip("#x_label#<br>#val# meldinger");
        $bar->values(array_values($data['sum']));
        $bar->colour(OFC_Colours::$colours[1]);
        $ofc->add_element($bar);
        $bar = new OFC_Charts_Area();
        $bar->text("Antall henvendelser");
        $bar->dot_style()->type("solid-dot")->dot_size(3)->halo_size(2)->tip("#x_label#<br>#val# henvendelser");
        $bar->values(array_values($data['su']));
        $bar->colour(OFC_Colours::$colours[0]);
        $ofc->add_element($bar);
        $ofc->axis_x()->label()->steps(2)->rotate(330)->labels(array_values($data['labels']));
        $ofc->axis_y()->set_numbers(0, max(max($data['sum']), max($data['su'])));
        $ofc->dark_colors();
        ess::$b->page->add_js('
function open_flash_chart_data()
{
	return ' . js_encode((string) $ofc) . ';
}');
        ess::$b->page->add_js_file(LIB_HTTP . '/swfobject/swfobject.js');
        ess::$b->page->add_js_domready('swfobject.embedSWF("' . LIB_HTTP . '/ofc/open-flash-chart.swf", "stats_support", "100%", 250, "9.0.0");');
        echo '
<div class="bg1_c small">
	<h2 class="bg1">Statistikk over henvendelser til support<span class="left2"></span><span class="right2"></span></h2>
	<div class="bg1" style="padding: 10px">
		<div id="stats_support"></div>
	</div>
</div>';
    }