diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..daf19b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/config.php +/public/img \ No newline at end of file diff --git a/.htaccess b/.htaccess deleted file mode 100644 index d62b84f..0000000 --- a/.htaccess +++ /dev/null @@ -1,3 +0,0 @@ -RewriteEngine on -RewriteRule ^doppelklinge/? /?p=doppelklinge [L] -RewriteRule ^vermessung/? /?p=vermessung [L] diff --git a/img/logo-big.png b/img/logo-big.png deleted file mode 100644 index 20bef06..0000000 Binary files a/img/logo-big.png and /dev/null differ diff --git a/inc/db.inc.php b/inc/db.inc.php new file mode 100644 index 0000000..4d70abb --- /dev/null +++ b/inc/db.inc.php @@ -0,0 +1,13 @@ +sql->dsn, + $config->sql->user, + $config->sql->password, + [ + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ + ] +); +?> diff --git a/inc/router.inc.php b/inc/router.inc.php index 31ecc23..f43f2a1 100644 --- a/inc/router.inc.php +++ b/inc/router.inc.php @@ -1,15 +1,15 @@ - 'doppelklinge', - 'vermessung' => 'vermessung', - 'default' => 'default' -]; - -ob_start(); -if(array_key_exists($_page, $routes)) - require_once("./pages/{$routes[$_page]}.page.php"); -else - require_once("./pages/{$routes['default']}.page.php"); - -$_content = ob_get_contents(); -ob_end_clean(); + 'doppelklinge', + 'vermessung' => 'vermessung', + 'knochen' => 'knochen', + 'default' => 'default' +]; + +ob_start(); +require_once __DIR__ . "/../pages/{$routes[array_key_exists($_page, $routes)?$_page:'default']}.php"; + +$_content = ob_get_contents(); +ob_end_clean(); diff --git a/inc/tpl.class.php b/inc/tpl.class.php index 8d2704f..a53a7b8 100644 --- a/inc/tpl.class.php +++ b/inc/tpl.class.php @@ -1,6 +1,7 @@ $value) $code = preg_replace('/{% ?yield ?' . $block . ' ?%}/', $value, $code); - $code = preg_replace('/{% ?yield ?(.*?) ?%}/i', '', $code); - return $code; + return preg_replace('/{% ?yield ?(.*?) ?%}/i', '', $code); } } ?> diff --git a/index.php b/index.php index d942089..8b84d90 100644 --- a/index.php +++ b/index.php @@ -1,27 +1,27 @@ -debug) { - tpl::view('tpl/' . $tpl->file, - array_merge([ - 'page' => $_page, - 'generated' => $generated - ], - gettype($tpl->data) !== 'string' ? $tpl->data : []) - ); -} -else { - echo "
";
-  print_r($_content);
-  echo "
"; -} +debug) { + tpl::view($tpl->file, + array_merge([ + 'page' => $_page, + 'generated' => $generated + ], + gettype($tpl->data) !== 'string' ? $tpl->data : []) + ); +} +else { + echo "
";
+  print_r($_content);
+  echo "
"; +} diff --git a/pages/default.page.php b/pages/default.page.php deleted file mode 100644 index 3561982..0000000 --- a/pages/default.page.php +++ /dev/null @@ -1,3 +0,0 @@ -.*): (?.*) \/ (?.*)/m", $progress, $tmp); - - for($i = 0; $i < count($tmp[0]); $i++) { - if(preg_match('/XP\:/', $tmp['task'][$i])) - continue; - - $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); - $list[$i]->left = $list[$i]->max - $list[$i]->act; - } - - 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' => '' - ]; -} diff --git a/pages/doppelklinge.php b/pages/doppelklinge.php new file mode 100644 index 0000000..188fe89 --- /dev/null +++ b/pages/doppelklinge.php @@ -0,0 +1,116 @@ + [ 'name' => 'Aufträge / Vermessungen', 'max' => 15000 ], + 'blut' => [ 'name' => 'Blutproben abgegeben', 'max' => 500 ], + 'gewebe' => [ 'name' => 'Gewebeproben abgegeben', 'max' => 750 ], + 'gnpc' => [ 'name' => 'Gruppen-NPCs getötet', 'max' => 5000 ], + 'npc' => [ 'name' => 'NPCs getötet', 'max' => 100000 ], + 'pflanzen' => [ 'name' => 'Pflanzen geerntet', 'max' => 1500 ], + 'unique' => [ 'name' => 'Unique-NPCs getötet', 'max' => 2500 ] +]; + +if(isset($_GET['c'])) { + $res = $db->prepare('select * from ft_doppelklinge where uuid = :uuid limit 1'); + $res->execute([ ':uuid' => $_GET['c'] ]); + $arr = $res->fetch($db::FETCH_ASSOC); + + $i = 0; + foreach($tasks as $type => $data) { + $list[$i] = (object)[ + 'task' => $data['name'], + 'act' => $arr[$type], + 'max' => $data['max'] + ]; + $list[$i]->percent = round($list[$i]->act / $list[$i]->max * 100, 2); + $list[$i]->left = $list[$i]->max - $list[$i]->act; + $i++; + } + + 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), + 'dt' => date('d.m.Y - H:i:s', strtotime($arr['created_at'])) + ]; + return; +} + +$progress = !empty($_POST['progress']) ? $_POST['progress'] : ''; + +if(!empty($progress)) { + $list = []; + preg_match_all("/(?.*): (?.*) \/ (?.*)/m", $progress, $tmp); + + for($i = 0; $i < count($tmp[0]); $i++) { + if(preg_match('/XP\:/', $tmp['task'][$i])) + continue; + + $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); + $list[$i]->left = $list[$i]->max - $list[$i]->act; + } + + $query = <<prepare($query); + $insert->execute([ + ':sessid' => session_id(), + ':auftrag' => $list[0]->act, + ':blut' => $list[1]->act, + ':gewebe' => $list[2]->act, + ':gnpc' => $list[3]->act, + ':npc' => $list[4]->act, + ':pflanzen' => $list[5]->act, + ':unique' =>$list[6]->act + ]); + + $uuid = $insert->fetch()->uuid; + + 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), + 'share' => $uuid + ]; +} +else { + $tpl['data'] = [ + 'progress' => '' + ]; +} diff --git a/pages/knochen.php b/pages/knochen.php new file mode 100644 index 0000000..e31ea64 --- /dev/null +++ b/pages/knochen.php @@ -0,0 +1,22 @@ +query(<<fetchAll($db::FETCH_GROUP); + +$tpl['data'] = [ + 'types' => [ + 'nimm' => 'Nimm Knochen weg', + 'lege' => 'Lege Knochen um' + ], + 'knochen' => [ + 'nimm' => $res['nimm'], + 'lege' => $res['lege'] + ] +]; diff --git a/pages/vermessung.page.php b/pages/vermessung.php similarity index 65% rename from pages/vermessung.page.php rename to pages/vermessung.php index 866813f..364bc72 100644 --- a/pages/vermessung.page.php +++ b/pages/vermessung.php @@ -1,5 +1,5 @@ $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] = 1; - else - $vms[$tmpdt]['user'][$tmp] += 1; + 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']); @@ -44,7 +58,7 @@ if(!empty($protocol)) { 'gold' => (int)str_replace('.', '', $res['gm'][$i]), 'amt' => $res['amt'][$i], 'laeufer' => $laeufer, - 'a' => (int)str_replace('.', '', $res['gm'][$i]) / (count($laeufer) + 1) + 'a' => $pro ]; } diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..dcd6aaa --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,8 @@ +RedirectMatch 404 /\.git + +RewriteEngine on +#RewriteRule ^doppelklinge/ /p=doppelklinge [L] +RewriteRule ^doppelklinge/?$ /?p=doppelklinge [L] +RewriteRule ^doppelklinge/([a-zA-Z0-9]{8})/?$ /?p=doppelklinge&c=$1 [L] +RewriteRule ^vermessung/? /?p=vermessung [L] +RewriteRule ^knochen/? /?p=knochen [L] \ No newline at end of file diff --git a/css/bootstrap.min.css b/public/css/bootstrap.min.css similarity index 100% rename from css/bootstrap.min.css rename to public/css/bootstrap.min.css diff --git a/css/style.css b/public/css/style.css similarity index 68% rename from css/style.css rename to public/css/style.css index 07b4eab..7a674ff 100644 --- a/css/style.css +++ b/public/css/style.css @@ -48,6 +48,10 @@ body { font-size: .75rem; } +#sidebarMenu { + width: 200px; +} + /* Navbar */ .navbar-brand { padding-top: .75rem; @@ -64,6 +68,30 @@ body { padding: .75rem 1rem; } +/* KnochenDB */ +.NavFrame+.NavFrame { + border-top-style: none; + border-top-style: hidden +} +.NavFrame p, .NavContent, .NavContent p { + font-size: 100% +} +.NavFrame { + margin: 0px; + padding: 2px; + border: 1px solid #aaaaaa; + text-align: center; + border-collapse: collapse; + font-size: 95%; + clear: both +} +.NavHead { + background-color: #efefef; + font-size: 100%; + font-weight: bold; + height: 1.6em +} + /* Footer */ footer { position: fixed; @@ -71,9 +99,3 @@ footer { width: 100%; background-color: var(--bs-gray-100); } - -/* custom */ -ul.list-top > li::before { - counter-increment: toplist; - content: "# " counter(toplist) ": "; -} diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..10ab191 --- /dev/null +++ b/public/index.php @@ -0,0 +1,2 @@ + -insgesamt {{ $percent }}% erledigt (ø {{ $avg }}%). +

insgesamt {{ $percent }}% erledigt (ø {{ $avg }}%).

+

Stand: {{ $dt }}

{% endif; %} {% endblock %} diff --git a/views/knochen.twig b/views/knochen.twig new file mode 100644 index 0000000..75dbe4f --- /dev/null +++ b/views/knochen.twig @@ -0,0 +1,29 @@ +{% extends layout.twig %} + +{% block title %}KnochenDB{% endblock %} + +{% block content %} +

von Phloks

+ +{% foreach($data['knochen'] as $key => $arr): %} +

{{ $data['types'][$key] }}:

+ {% foreach($arr as $row): %} + + {% endforeach %} +{% endforeach %} +{% endblock %} diff --git a/tpl/layout.html b/views/layout.twig similarity index 78% rename from tpl/layout.html rename to views/layout.twig index 06b3c46..05d1e75 100644 --- a/tpl/layout.html +++ b/views/layout.twig @@ -1,52 +1,53 @@ - - - - - - - {% yield title %} - - - - - - -
-
- - -
-

{% yield title %}

-
- {% yield content %} -
-
-
- -
-
- Made with by DALL·E and ChatGPT • Generated in {{ $generated }}s -
-
- - - + + + + + + + {% yield title %} + + + + + + +
+
+ + +
+

{% yield title %}

+
+ {% yield content %} +
+
+
+
+ +
+
+ Made with by DALL·E and ChatGPT • Generated in {{ $generated }}s +
+
+ + + diff --git a/tpl/vermessung.html b/views/vermessung.twig similarity index 64% rename from tpl/vermessung.html rename to views/vermessung.twig index 6b7aa7a..1db60d6 100644 --- a/tpl/vermessung.html +++ b/views/vermessung.twig @@ -1,4 +1,4 @@ -{% extends tpl/layout.html %} +{% extends layout.twig %} {% block title %}irgendwas mit Vermessungen{% endblock %} @@ -26,14 +26,25 @@
Topliste:
-
    - {% foreach($newest['user'] as $name => $c): %} -
  • - {{ $name }} - {{ $c }} Vermessungen -
  • - {% endforeach; %} -
+ + + + + + + + + {% $i = 0; %} + {% foreach($newest['user'] as $name => $player): %} + + + + + + + {% endforeach; %} + +
#SpielerVermessungenGold
{{ ++$i }}{{ $name }}{{ $player['count'] }}{{ number_format($player['gold'], 0, '', '.') }}
@@ -46,7 +57,7 @@ Datum Summe - à Spieler + à Amtsteher Läufer @@ -55,8 +66,8 @@ {% foreach($newest['list'] as $tmp): %} {{ $tmp['datum'] }} - {{ $tmp['gold'] }} gm - {{ $tmp['a'] }} gm + {{ number_format($tmp['gold'], 0, '', '.') }} gm + {{ number_format($tmp['a'], 0, '', '.') }} gm {{ $tmp['amt'] }} {{ implode(', ', $tmp['laeufer']) }} @@ -83,23 +94,21 @@ let gm = 0; let cvm = 0; + let i = 1; - for(let [ user, count ] of Object.entries(vm.user)) { + for(let [ name, player ] of Object.entries(vm.user)) { + console.log(player); // fill toplist - const li = document.createElement('li'); - li.classList.add('list-group-item', 'd-flex', 'justify-content-between', 'align-items-center', 'p-1'); - li.innerText = user; - const span = document.createElement('span'); - span.classList.add('badge', 'bg-primary', 'rounded-pill'); - span.innerText = `${count} Vermessungen`; - li.insertAdjacentElement('beforeend', span); - toplist.insertAdjacentElement('beforeend', li); + const tr = document.createElement('tr'); + tr.innerHTML = `${i}${name}${player.count}${player.gold.toLocaleString('de-DE')}`; + toplist.insertAdjacentElement('beforeend', tr); + i++; } - + for(let entry of vm.list) { // fill vmlist const tr = document.createElement('tr'); - tr.innerHTML = `${entry.datum}${entry.gold} gm${entry.a} gm${entry.amt}${entry.laeufer.join(', ')}`; + tr.innerHTML = `${entry.datum}${entry.gold.toLocaleString('de-DE')} gm${entry.a.toLocaleString('de-DE')} gm${entry.amt}${entry.laeufer.join(', ')}`; vmlist.insertAdjacentElement('beforeend', tr); }