wah.moe/guestbook/index.php

76 lines
2.2 KiB
PHP
Raw Normal View History

2023-05-25 19:12:25 +00:00
<?php $db = new PDO("sqlite:/srv/guestbook.db"); ?>
2022-10-02 17:10:23 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Global -->
2022-11-15 22:20:35 +00:00
<?php require('../inc/header.inc.php'); ?>
2022-10-02 17:10:23 +00:00
<!-- Page-specific -->
2022-12-20 20:55:38 +00:00
<?php require_once('../inc/title.inc.php') ?>
<link rel="shortcut icon" href="../res/img/icons/ico/help-book.ico" type="image/x-icon">
2022-10-02 17:10:23 +00:00
<meta property="og:title" content="Guestbook">
<meta property="og:description" content="h">
<meta property="og:image" content="/res/img/icons/png/help-book.png">
2022-10-02 17:10:23 +00:00
</head>
<body>
<div class="page">
2022-11-15 22:20:35 +00:00
<?php require('../inc/nav.inc.php') ?>
2022-10-02 17:10:23 +00:00
<div id="pagebody">
<div id="content">
<br>
<form action="submit.php" method="post">
2022-11-22 08:52:35 +00:00
<fieldset>
<legend>Add Entry</legend>
<table class="form">
<tr>
2023-05-25 19:12:25 +00:00
<td class="form"><i>Form temporarily disabled</i></td>
2022-11-22 08:52:35 +00:00
</tr>
</table>
</fieldset>
2022-10-02 17:10:23 +00:00
</form>
<?php
// Pain
$count_query = $db->prepare('SELECT COUNT(*) FROM Entries');
$count_query->execute();
$count = $count_query->fetch()[0];
echo '<h1>Entries <small>(' . $count . ' total)</small></h1>';
// Prepare SELECT statement.
2023-05-25 19:12:25 +00:00
$select = "SELECT name, message, show_info, show_ip, ip, submitted, browser_info FROM Entries ORDER BY submitted DESC";
2022-10-02 17:10:23 +00:00
$stmt = $db->prepare($select);
// Execute statement.
$stmt->execute(); // ID between 1 and 3.
// Get the results.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
2022-10-02 17:10:23 +00:00
foreach($results as $row) {
echo '<table border="1" width="500"><tr><td><pre>';
$submittedRaw = $row['submitted'];
$submittedDT = new DateTime("@$submittedRaw");
$submitted = $submittedDT->format('H:i:s - Y-m-d');
$browser = get_browser(null, true);
$sys = $browser['parent'] . ' (' . $browser['platform_description'] . ' ' . $browser['platform_version'] . ')';
echo 'Name: ' . $row['name'] . PHP_EOL;
if ($row['show_ip']) echo 'IP: ' . $row['ip'] . PHP_EOL;
if ($row['show_info']) echo 'Sys: ' . $row['browser_info'] . PHP_EOL;
echo 'Date: ' . $submitted . PHP_EOL . PHP_EOL;
echo $row['message'];
echo '</pre></td></tr></table><br>';
}
?>
2022-12-01 09:27:43 +00:00
2022-10-02 17:10:23 +00:00
</div> <!-- content -->
<div id="footer" class="pagefooter">
2022-11-15 22:20:35 +00:00
<?php $file = __FILE__;require('../inc/footer.inc.php'); ?>
2022-10-02 17:10:23 +00:00
</div> <!-- footer -->
</div> <!-- pagebody -->
</div> <!-- page -->
</body>
</html>