From 8ace1a5c4551680af805b2fe40b212c459d107b9 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 9 Jan 2015 11:53:25 -0800 Subject: [PATCH] web: add script for getting stats by client brand --- html/user/brand_stats.php | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 html/user/brand_stats.php diff --git a/html/user/brand_stats.php b/html/user/brand_stats.php new file mode 100644 index 0000000000..7cb1e6936d --- /dev/null +++ b/html/user/brand_stats.php @@ -0,0 +1,69 @@ +. + +// show statistics by client "brand" + +require_once("../inc/util.inc"); + +function show_form() { + page_head("Show statistics by client brand"); + echo " +
+ Select brand: +

+ HTP Power to Give +

+ + "; + page_tail(); +} + +function show_stats($brand) { + switch ($brand) { + case 1: + $x = "HTC Power to Give"; + break; + default: + error_page("invalid brand"); + } + $hosts = BoincHost::enum("serialnum like '%$x%'"); + $n = 0; + $t = 0; + $a = 0; + foreach($hosts as $h) { + $t += $h->total_credit; + $a += $h->expavg_credit; + if ($h->expavg_credit > .1) $n++; + } + page_head("Stats for $x"); + start_table(); + row2("Active devices", $n); + row2("Average daily credit", $a); + row2("Total credit", $t); + end_table(); + page_tail(); +} + +$brand = get_int("brand", true); +if ($brand) { + show_stats($brand); +} else { + show_form(); +} + +?>