2022-12-20 11:21:31 +00:00
|
|
|
<?php
|
|
|
|
$tpl['file'] = 'doppelklinge.html';
|
|
|
|
$tpl['data'] = [];
|
|
|
|
|
|
|
|
$progress = !empty($_POST['progress']) ? $_POST['progress'] : '';
|
|
|
|
|
|
|
|
if(!empty($progress)) {
|
|
|
|
$list = [];
|
|
|
|
preg_match_all("/(?<task>.*): (?<act>.*) \/ (?<max>.*)/m", $progress, $tmp);
|
|
|
|
|
|
|
|
for($i = 0; $i < count($tmp[0]); $i++) {
|
2022-12-22 06:06:30 +00:00
|
|
|
if(preg_match('/XP\:/', $tmp['task'][$i]))
|
|
|
|
continue;
|
|
|
|
|
2022-12-20 11:21:31 +00:00
|
|
|
$list[$i] = (object)[
|
|
|
|
'task' => trim($tmp['task'][$i]),
|
|
|
|
'act' => (int)str_replace('.', '', $tmp['act'][$i]),
|
|
|
|
'max' => (int)str_replace('.', '', $tmp['max'][$i])
|
|
|
|
];
|
|
|
|
$list[$i]->percent = round($list[$i]->act / $list[$i]->max * 100, 2);
|
2022-12-22 06:06:30 +00:00
|
|
|
$list[$i]->left = $list[$i]->max - $list[$i]->act;
|
2022-12-20 11:21:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usort($list, function($a, $b) { return $b->percent <=> $a->percent; });
|
|
|
|
|
|
|
|
$act = $max = $avg = 0;
|
|
|
|
for($i = 0; $i < 5; $i++) {
|
|
|
|
$act += $list[$i]->act;
|
|
|
|
$max += $list[$i]->max;
|
|
|
|
$avg += $list[$i]->percent;
|
|
|
|
}
|
|
|
|
$percent = round($act / $max * 100, 2);
|
|
|
|
|
|
|
|
$tpl['data'] = [
|
|
|
|
'progress' => $progress,
|
|
|
|
'list' => $list,
|
|
|
|
'percent' => $percent,
|
|
|
|
'avg' => round($avg / 5, 2)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$tpl['data'] = [
|
|
|
|
'progress' => ''
|
|
|
|
];
|
|
|
|
}
|