fwtrash/pages/vermessung.page.php

61 lines
1.5 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],
'laeufer' => $laeufer
];
}
$tpl['data'] = [
'protocol' => $protocol,
'vms' => $vms,
'newest' => array_shift($vms)
];
}
else {
$tpl['data'] = [
'protocol' => $protocol
];
}