diff options
Diffstat (limited to 'includes/member.php')
-rw-r--r-- | includes/member.php | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/includes/member.php b/includes/member.php new file mode 100644 index 0000000..ad7995f --- /dev/null +++ b/includes/member.php @@ -0,0 +1,84 @@ +<?php global $system; global $systemCommonName; global $systemID; global $member; global $memberData; global $memberCommonName; global $memberID; $title = $memberCommonName . " ยท " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; + +function timeAgo($time): string { + if (!is_numeric($time)) { + $time = strtotime($time); + } + + $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; + $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); + + $now = time(); + + $difference = $now - $time; + if ($difference <= 10 && $difference >= 0) { + return $tense = "now"; + } elseif ($difference > 0) { + $tense = "ago"; + } else { + $tense = "later"; + } + + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { + $difference /= $lengths[$j]; + } + + $difference = round($difference); + + $period = $periods[$j] . ($difference >1 ? "s" :''); + return "{$difference} {$period} {$tense} "; +} + +$metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "-" . $memberID . "-metadata.json"), true); + +?> + +<br> +<div class="container"> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.php"; ?> + <br> + + <?php global $isLoggedIn; if ($isLoggedIn): ?> + <div class="alert alert-dark"> + <details> + <summary>Private administrator information</summary> + <ul style="margin-bottom:0;"> + <li><b>ID:</b> <code><?= $memberID ?></code> (<code><?= $systemID . "/" . $memberID ?></code>, <?= $memberData["name"] ?>)</li> + <li><b>Reduced name:</b> <?= getMiniName($memberData["display_name"] ?? $member["name"]) ?></li> + <li><b>Shared memory access:</b> <code><?= $metadata["shared_memory"] ?></code> (<?= $metadata["shared_memory"] === 2 ? "Full direct access" : ($metadata["shared_memory"] === 0 ? "No direct access" : "Partial direct access") ?>)</li> + <li><b>Protector:</b> <code><?= $metadata["protector"] ? "1" : "0" ?></code> (<?= $metadata["protector"] ? "Yes" : "No" ?>)</li> + <li><b>Little:</b> <code><?= $metadata["little"] ?></code> (<?= $metadata["little"] === 2 ? "Is a little" : ($metadata["little"] === 1 ? "Is an age regressor" : "No") ?>)</li> + <li><b>Relations count:</b> <code><?= count($metadata["marefriends"]) + count($metadata["sisters"]) ?></code></li> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; $score = calculateScore($metadata, $memberData["display_name"] ?? $memberData["name"]); ?> + <li> + <b>Score breakdown:</b> <code><?= $score["total"] ?></code> + <details> + <summary>Show details</summary> + <ul> + <li><b>Host score:</b> <code><?= $score["host"] ?></code></li> + <li><b>Relationships score:</b> <code><?= $score["relations"] ?></code></li> + <li><b>Fictive score:</b> <code><?= $score["fictive"] ?></code></li> + <li><b>Median score:</b> <code><?= $score["median"] ?></code></li> + <li><b>Species score:</b> <code><?= $score["species"] ?></code></li> + <li><b>Little score:</b> <code><?= $score["little"] ?></code></li> + <li><b>Not talking score:</b> <code><?= $score["not_talking"] ?></code></li> + <li><b>Protector score:</b> <code><?= $score["protector"] ?></code></li> + <li><b>Name score:</b> <code><?= $score["name"] ?></code></li> + <li><b>Shared memory score:</b> <code><?= $score["shared_memory"] ?></code></li> + </ul> + </details> + </li> + </ul> + </details> + </div> + <?php endif; ?> + + <div id="page-content"> + <?php global $isLoggedIn; if ($isLoggedIn): ?> + <small style="opacity:.5;display:block;">(<a href="/edit/<?= $system ?>/<?= $memberData['name'] ?>">edit</a>)</small> + <?php endif; ?> + <?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html") ? file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-$memberID-content.html") : "<i>This page is empty.</i>" ?> + </div> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file |