diff --git a/public/css/dk.css b/public/css/dk.css
index ce56c18..76d3131 100644
--- a/public/css/dk.css
+++ b/public/css/dk.css
@@ -35,7 +35,7 @@ main > section {
padding: 4px;
}
-main > section > section:not(:last-child) {
+main > section > section {
margin-bottom: 2rem;
}
diff --git a/src/database.php b/src/database.php
index 5416432..bcc7bd7 100644
--- a/src/database.php
+++ b/src/database.php
@@ -9,6 +9,9 @@ class Database extends SQLite3
public array $log = [];
public float $query_time = 0;
+ /**
+ * Make a big, chonky connection to our SQLite database.
+ */
public function __construct(string $db_path)
{
parent::__construct($db_path);
@@ -18,6 +21,10 @@ class Database extends SQLite3
parent::exec('PRAGMA temp_store = MEMORY');
}
+ /**
+ * Query the database. Uses prepared statements, and your choise of placeholder syntax. (:key or ?) Logs
+ * the query in the class.
+ */
public function query(string $query, array $params = []): SQLite3Result|false
{
$p = strpos($query, '?') !== false;
@@ -31,6 +38,9 @@ class Database extends SQLite3
return $r;
}
+ /**
+ * Perform a result-less query on the database.
+ */
public function exec(string $query): bool
{
$start = microtime(true);
@@ -39,6 +49,10 @@ class Database extends SQLite3
return $r;
}
+ /**
+ * Determines whether a given value exists in a given column in a given table. Can optionally make it
+ * case-sensitive!
+ */
public function exists(string $table, string $column, mixed $value, bool $case_insensitive = true): bool
{
if ($case_insensitive) {
@@ -51,6 +65,9 @@ class Database extends SQLite3
return $result->fetchArray(SQLITE3_NUM) !== false;
}
+ /**
+ * Log the query, including the time it took. Increment the query counter.
+ */
private function log(string $query, float $time_taken): void
{
$this->count++;
@@ -58,6 +75,9 @@ class Database extends SQLite3
$this->log[] = [$query, $time_taken];
}
+ /**
+ * Return the correct SQLite3 type for the given value.
+ */
private function getSQLiteType(mixed $value): int
{
return match (true) {
diff --git a/src/explore.php b/src/explore.php
index a39b67c..fdc6eb3 100644
--- a/src/explore.php
+++ b/src/explore.php
@@ -25,7 +25,7 @@ function move()
$town = get_town_by_xy($longitude, $latitude);
if ($town !== false) {
require_once __DIR__ . '/towns.php';
- travelto($town['id'], false);
+ Towns\travelto($town['id'], false);
return;
}
diff --git a/src/lib.php b/src/lib.php
index c1af9f3..9a5879d 100644
--- a/src/lib.php
+++ b/src/lib.php
@@ -233,7 +233,7 @@ function checkcookies()
}
$row = $query->fetchArray(SQLITE3_ASSOC);
set_cookie('dkgame', implode(" ", $theuser), (int) $theuser[3] === 1 ? time() + 31536000 : 0);
- db()->exec('UPDATE users SET onlinetime = CURRENT_TIMESTAMP WHERE id = ?;', [$theuser[0]]);
+ db()->query('UPDATE users SET onlinetime = CURRENT_TIMESTAMP WHERE id = ?;', [$theuser[0]]);
}
return $row;
diff --git a/templates/leftnav.php b/templates/leftnav.php
index 1b50df3..ab6d762 100644
--- a/templates/leftnav.php
+++ b/templates/leftnav.php
@@ -28,7 +28,7 @@ $template = <<Home
{{forumslink}}
{{adminlink}}
- Change Password
+ Change Password
Log Out
Help