diff options
Diffstat (limited to 'src/application/common.php')
-rw-r--r-- | src/application/common.php | 12 |
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)))); +} |