fwtrash/pages/vermessung.page.php

62 lines
1.6 KiB
PHP
Raw Normal View History

2022-12-20 11:21:31 +00:00
<?php
$tpl['file'] = 'vermessung.html';
$tpl['data'] = [];
$tpl['debug'] = false;
$protocol = !empty($_POST['protocol']) ? $_POST['protocol'] : '';
if(!empty($protocol)) {
preg_match_all("/(?<datetime>.*)\t(?<amt>.*) führt mit (?<laeufer>.*) eine.*erwirtschaftet (?<gm>.*) Goldmünzen/m", $protocol, $res);
$dtact = date('m.Y');
$vms = $newest = [];
for($i = 0; $i < count($res['datetime']); $i++) {
$tmpdt = date('m.Y', strtotime($res['datetime'][$i]));
if(!array_key_exists($tmpdt, $vms)) {
$vms[$tmpdt] = [
'user' => [],
'gm' => 0,
'list' => [],
'dtact' => $tmpdt
];
}
if(!array_key_exists($res['amt'][$i], $vms[$tmpdt]['user']))
$vms[$tmpdt]['user'][$res['amt'][$i]] = 1;
else
$vms[$tmpdt]['user'][$res['amt'][$i]] += 1;
$laeufer = explode(', ', str_replace(' und ', ', ', trim($res['laeufer'][$i], ',')));
foreach($laeufer as $tmp) {
if(!array_key_exists($tmp, $vms[$tmpdt]['user']))
$vms[$tmpdt]['user'][$tmp] = 1;
else
$vms[$tmpdt]['user'][$tmp] += 1;
}
arsort($vms[$tmpdt]['user']);
$vms[$tmpdt]['gm'] += (int)str_replace('.', '', $res['gm'][$i]);
$vms[$tmpdt]['list'][] = [
'datum' => $res['datetime'][$i],
'gold' => (int)str_replace('.', '', $res['gm'][$i]),
'amt' => $res['amt'][$i],
2022-12-29 02:59:51 +00:00
'laeufer' => $laeufer,
'a' => (int)str_replace('.', '', $res['gm'][$i]) / (count($laeufer) + 1)
2022-12-20 11:21:31 +00:00
];
}
$tpl['data'] = [
'protocol' => $protocol,
'vms' => $vms,
'newest' => array_shift($vms)
];
}
else {
$tpl['data'] = [
'protocol' => $protocol
];
}