76 lines
1.9 KiB
PHP
76 lines
1.9 KiB
PHP
<?php
|
|
$tpl['file'] = 'vermessung.twig';
|
|
$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
|
|
];
|
|
}
|
|
|
|
$laeufer = explode(', ', str_replace(' und ', ', ', trim($res['laeufer'][$i], ',')));
|
|
$pro = (int)str_replace('.', '', $res['gm'][$i]) / (count($laeufer) + 1);
|
|
|
|
if(!array_key_exists($res['amt'][$i], $vms[$tmpdt]['user'])) {
|
|
$vms[$tmpdt]['user'][$res['amt'][$i]] = [
|
|
'gold' => $pro,
|
|
'count' => 1
|
|
];
|
|
}
|
|
else {
|
|
$vms[$tmpdt]['user'][$res['amt'][$i]]['gold'] += $pro;
|
|
$vms[$tmpdt]['user'][$res['amt'][$i]]['count'] += 1;
|
|
}
|
|
|
|
foreach($laeufer as $tmp) {
|
|
if(!array_key_exists($tmp, $vms[$tmpdt]['user'])) {
|
|
$vms[$tmpdt]['user'][$tmp] = [
|
|
'gold' => $pro,
|
|
'count' => 1
|
|
];
|
|
}
|
|
else {
|
|
$vms[$tmpdt]['user'][$tmp]['gold'] += $pro;
|
|
$vms[$tmpdt]['user'][$tmp]['count'] += 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,
|
|
'a' => $pro
|
|
];
|
|
}
|
|
|
|
$tpl['data'] = [
|
|
'protocol' => $protocol,
|
|
'vms' => $vms,
|
|
'newest' => array_shift($vms)
|
|
];
|
|
}
|
|
else {
|
|
$tpl['data'] = [
|
|
'protocol' => $protocol
|
|
];
|
|
}
|