summaryrefslogtreecommitdiff
path: root/src/application/common.php
diff options
context:
space:
mode:
authorJonas Kohl2024-12-26 20:12:34 +0100
committerJonas Kohl2024-12-26 20:12:34 +0100
commit686fff945e0b4697aa74da404ce90534bb7b121d (patch)
treecb5582c8d118cb480f2978fa821950f4a2259401 /src/application/common.php
parent11fed2c8ce3dd38fe686e7b27db738f64373fe3d (diff)
Add async email and topic subscribingv0.7.2
Diffstat (limited to 'src/application/common.php')
-rw-r--r--src/application/common.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/application/common.php b/src/application/common.php
new file mode 100644
index 0000000..113d598
--- /dev/null
+++ b/src/application/common.php
@@ -0,0 +1,12 @@
+<?php
+
+use mystic\forum\Database;
+use mystic\forum\exceptions\DatabaseConnectionException;
+
+function get_db(): Database {
+ return new Database(Database::getConnectionString("db", getenv("POSTGRES_USER"), getenv("POSTGRES_PASSWORD"), getenv("POSTGRES_DBNAME")));
+}
+
+function quote_message(string $message): string {
+ return implode("\n", array_map(fn($ln) => "> $ln", preg_split('~(*BSR_ANYCRLF)\R~', trim($message))));
+}