diff options
Diffstat (limited to 'src/index.php')
-rw-r--r-- | src/index.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/index.php b/src/index.php index 8036a19..0580523 100644 --- a/src/index.php +++ b/src/index.php @@ -9,6 +9,8 @@ use mystic\forum\orm\Topic; use mystic\forum\orm\TopicLogMessage; use mystic\forum\orm\User; use mystic\forum\orm\UserPermissions; +use mystic\forum\orm\PendingEmail; +use mystic\forum\orm\Subscription; use mystic\forum\utils\RequestUtils; use mystic\forum\utils\StringUtils; use Twig\Environment; @@ -244,11 +246,11 @@ function expandTags(string $contents): string { }, $contents); } -function renderPostSummary(string $contents): string { +function renderPostSummary(string $contents, int $maxLength = 100): string { $contents = renderPost($contents); // remove spoiler contents so they don't appear in summaries $contents = preg_replace('/<!--##SPOILER_START##-->(.*?)<!--##SPOILER_END##-->/s', '[ ' . __("Spoiler") . ' ]', $contents); - return htmlentities(html_entity_decode(StringUtils::truncate(strip_tags($contents), 100))); + return htmlentities(html_entity_decode(StringUtils::truncate(strip_tags($contents), $maxLength))); } function renderPost(string $contents): string { @@ -299,6 +301,7 @@ function env(string $key): ?string { require_once __DIR__ . "/vendor/autoload.php"; require_once __DIR__ . "/application/i18n.php"; +require_once __DIR__ . "/application/common.php"; if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["lang"])) { parse_str($_SERVER["QUERY_STRING"], $query); @@ -319,7 +322,7 @@ i18n_locale($user_locale); $db = null; try { - $db = new Database(Database::getConnectionString("db", getenv("POSTGRES_USER"), getenv("POSTGRES_PASSWORD"), getenv("POSTGRES_DBNAME"))); + $db = get_db(); } catch (DatabaseConnectionException $ex) { msg_error( __("Failed to connect to database:\n%details%", [ @@ -337,6 +340,8 @@ $db->ensureTable(Topic::class); $db->ensureTable(Post::class); $db->ensureTable(Attachment::class); $db->ensureTable(TopicLogMessage::class); +$db->ensureTable(PendingEmail::class); +$db->ensureTable(Subscription::class); $superuser = new User(); $superuser->id = "SUPERUSER"; |