Mercurial > hg > batmud > misc
changeset 150:35c93e4727ea misc
Added initial alloy stats page.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 21 Dec 2010 17:04:09 +0000 |
parents | 762e30af53f6 |
children | 4c0b50a5e7b5 |
files | materials/stats.php |
diffstat | 1 files changed, 61 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/materials/stats.php Tue Dec 21 17:04:09 2010 +0000 @@ -0,0 +1,61 @@ +<? +$pageTitle = "Alloy combination submitter statistics"; + +require "mcommon.inc.php"; +require "guids.inc.php"; + +$users = array(); +$total = 0; + +foreach ($submitGUIDS as $guid => $user) { + $g = strtolower($guid); + $filename = "data-".strtolower($user).".log"; + $file = @fopen($filename, "r"); + + if ($file !== FALSE) { + while (($line = fgets($file, 1024)) !== false) { + if (preg_match("/^(.*?)#(.*?)=(.*)$/", strtolower($line), $m)) { + if ($m[1] == $g) { + $total++; + $com = explode("+", $m[2]); + $users[$user]["tries"]++; + + if (!isset($users[$user]["combo"][$com[0]][$com[1]]) && !isset($users[$user]["combo"][$com[1]][$com[0]])) { + $users[$user]["combo"][$com[0]][$com[1]] = $m[3]; + } + } + } + } + fclose($file); + } +} + +function cmp($a, $b) +{ + return $b["tries"] - $a["tries"]; +} + +uasort($users, "cmp"); + +printPageHeader($pageTitle); +?> +<h1><? echo $pageTitle ?></h1> +<table> + <tr> + <th>User</th> + <th>Submitted tries</th> + <th>Different combos</th> + </tr> +<? + +$combos = 0; +foreach ($users as $user => $data) { + echo " <tr><td>".$user."</td><td>".$data["tries"]."</td><td>".count($data["combo"])."</td></tr>\n"; + $combos += count($data["combo"]); +} +?> +</table> +<? +echo "<p><b>$total</b> user-submitted tries, <b>".$combos."</b> total user-submitted combos.</p>\n"; +printPageFooter(); +?>