102 lines
3.8 KiB
PHP
102 lines
3.8 KiB
PHP
<?php
|
|
require_once('./config/config.php');
|
|
|
|
// Error reporting
|
|
if ($meta['production'] == false) {
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
}
|
|
|
|
// Connect to database, pull mod log data, then close connection
|
|
$database['connection'] = pg_connect("host=" . $database['host'] . " port=" . $database['port'] . " dbname=" . $database['dbname'] . " user=" . $database['user'] . " password=" . $database['password']) or die("database connection failed");
|
|
$database['query'] = 'SELECT * FROM ' . $database['table'];
|
|
$database['result'] = pg_query($database['connection'], $database['query']);
|
|
pg_close($database['connection']);
|
|
|
|
// Unscrew all the arrays lol
|
|
while ($line = pg_fetch_array($database['result'], null, PGSQL_ASSOC)) {
|
|
foreach ($line as $key => $value) {
|
|
$result[$line['id']] = [
|
|
'data' => json_decode($line['data'], true),
|
|
'inserted_at' => $line['inserted_at'],
|
|
'updated_at' => $line['updated_at']
|
|
];
|
|
}
|
|
}
|
|
|
|
// Free up some memory
|
|
pg_free_result($database['result']);
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<!-- -->
|
|
<title><?= $instance['name'] ?> Mod Log</title>
|
|
|
|
<!-- Stylesheets -->
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="/css/page.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<!-- Nav -->
|
|
<nav class="navbar bg-body-tertiary">
|
|
<div class="container">
|
|
<?= $instance['name'] ?> Mod Log
|
|
<div class="navbar-nav">
|
|
<a href="<?= $instance['url'] ?>" class="nav-link">Go to instance →</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Page Content -->
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col">
|
|
<table class="table table-striped table-hover text-center">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">ID</th>
|
|
<th scope="col">User</th>
|
|
<th scope="col">Action</th>
|
|
<th scope="col">Message</th>
|
|
<th scope="col">Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($result as $key => $value) :?>
|
|
<?php if (in_array($value["data"]["action"], $meta['actions'])) :?>
|
|
<tr>
|
|
<th scope="row"><?= $key ?></th>
|
|
<td><?= $value["data"]["actor"]["nickname"] ?></td>
|
|
<td><?= $value["data"]["action"] ?></td>
|
|
<td class="text-start"><?= $value["data"]["message"] ?></td>
|
|
<td><?= $value["inserted_at"] ?></td>
|
|
</tr>
|
|
<?php endif ?>
|
|
<?php endforeach ?>
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Footer -->
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col text-center">
|
|
<p>From <a href="https://labyrinth.zone/users/Velveteen" target="_blank">Vel</a>, With Love 💖
|
|
<a href="https://git.void.lgbt/Velveteen/akkoma-mod-log" target="_blank">Source Code</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|