diff options
| author | ilotterytea <iltsu@alright.party> | 2025-12-11 01:05:49 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-12-11 01:05:49 +0500 |
| commit | e8b0b4769d013862a54c273931ac4456c486e9ab (patch) | |
| tree | 3a46fc97038b5fcc166af4a8625a5e22c5a127e7 /system/reports/index.php | |
| parent | b852b37bf1a8b55d5d00629f2cbe510556e7360a (diff) | |
feat: report page (for mods)
Diffstat (limited to 'system/reports/index.php')
| -rw-r--r-- | system/reports/index.php | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/system/reports/index.php b/system/reports/index.php new file mode 100644 index 0000000..3109adc --- /dev/null +++ b/system/reports/index.php @@ -0,0 +1,108 @@ +<?php +include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/partials.php"; +include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/accounts.php"; +include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/alert.php"; +include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/config.php"; +include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/utils.php"; + +if (!CONFIG['reports']['enable']) { + generate_alert("/404.php", "Reports are disabled", 405); + exit; +} + +if (!authorize_user(true) || !$_SESSION["user_role"]["permission_report_review"]) { + generate_alert("/404.php", "Not enough permissions", 403); + exit; +} + +$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']); +$reports = $db->query("SELECT r.id, u.username AS sender_name, r.contents FROM reports r + JOIN users u ON u.id = r.sender_id + WHERE r.resolved_by IS NULL + ORDER BY r.sent_at DESC +"); +$reports->execute(); + +$reports = $reports->fetchAll(PDO::FETCH_ASSOC); + +$report = $reports[0] ?? null; + +if (isset($_GET["id"])) { + $stmt = $db->prepare("SELECT r.id, u.id AS sender_id, u.username AS sender_name, r.contents, r.sent_at, resolved_by, response_message FROM reports r + JOIN users u ON u.id = r.sender_id + WHERE r.id = ? + "); + + $stmt->execute([$_GET["id"]]); + $report = $stmt->fetch(PDO::FETCH_ASSOC) ?? null; +} +?> +<!DOCTYPE html> +<html> + +<head> + <title>Report review - <?= CONFIG['instance']['name'] ?></title> + <link rel="stylesheet" href="/static/style.css"> + <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> +</head> + +<body> + <div class="container"> + <div class="wrapper"> + <?php html_navigation_bar() ?> + <?php display_alert() ?> + <section class="content row"> + <section class="box"> + <div class="box navtab">System panel - Report review section</div> + <div class="box content"> + <?php foreach ($reports as $r): ?> + <a href="/system/reports/?id=<?= $r['id'] ?>"><b><?= substr($r['contents'], 0, 10) ?>...</b> + <span style="font-size:10px;">by <?= $r['sender_name'] ?></span></a> + <?php endforeach; ?> + <?php if (empty($reports)): ?> + <p>Everything is clear. Good job!</p> + <?php endif; ?> + </div> + </section> + <?php if ($report != null): ?> + <section class="content"> + <div class="box"> + <div class="box navtab">Report</div> + <div class="box content"> + <textarea disabled style="resize:none; height:250px;"><?= $report['contents'] ?></textarea> + </div> + </div> + <div class="box"> + <table class="vertical left"> + <tr> + <th>Reported by</th> + <td><a + href="/users.php?id=<?= $report['sender_id'] ?>"><?= $report['sender_name'] ?></a> + (<?= format_timestamp(time() - strtotime($report['sent_at'])) ?> ago)</td> + </tr> + <tr> + <th>Status</th> + <td> + <?php if (isset($report['resolved_by'])): ?> + <b style="color:green">Resolved</b> + <?php else: ?> + <b style="color:red">Unresolved</b> + <?php endif; ?> + </td> + </tr> + </table> + </div> + <form action="/system/reports/answer.php" method="post" class="box row small-gap"> + <input type="text" name="id" value="<?= $report['id'] ?>" style="display:none;"> + <textarea name="response" required placeholder="Write your response here..." + style="resize:none;height:128px;" class="grow"></textarea> + <button type="submit" class="green big">Send</button> + </form> + </section> + <?php endif; ?> + </section> + </div> + </div> +</body> + +</html>
\ No newline at end of file |
