From 39e3018222ea4f55fb2ec048af4eebed85077be7 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Thu, 3 Apr 2025 11:48:17 +0300 Subject: [PATCH] Add more extension checks --- README.md | 3 ++- chat.php | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 19b7fe3..942b9f4 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,12 @@ Features: Installation Instructions: -------------------------- -You'll need to have php with intl, gettext, pdo, pcre, mbstring and date extension, and a web-server installed. +You'll need to have php with gettext, pdo, pcre, mbstring and date extension, and a web-server installed. You will also need the pdo_sqlite, pdo_mysql or pdo_pgsql extension, depending on which database you choose. Optionally, you can install: - the gd extension for the captcha feature - the json extension for save/restore +- the intl extension for browser language detection - a memcached server and the memcached extension and change the configuration to use memcached. This will lessen the database load a bit. - a MySQL or PostgreSQL server to use as an external database instead of SQLite - the libsodium extension (PHP >= 7.2) for encryption of messages and notes in the database diff --git a/chat.php b/chat.php index 11d4229..a06c5b1 100644 --- a/chat.php +++ b/chat.php @@ -64,9 +64,6 @@ const LANGUAGES = [ 'zh-Hans' => ['name' => '简体中文', 'locale' => 'zh_CN', 'dir' => 'ltr'], 'zh-Hant' => ['name' => '正體中文', 'locale' => 'zh_TW', 'dir' => 'ltr'], ]; -if(!extension_loaded('mbstring')){ - send_fatal_error(sprintf(_('The %s extension of PHP is required, please install it first.'), 'mbstring')); -} load_config(); $U=[];// This user data $db = null;// Database connection @@ -83,6 +80,12 @@ if(!isset($_REQUEST['session']) && isset($_COOKIE[COOKIENAME])){ } $session = preg_replace('/[^0-9a-zA-Z]/', '', $session); load_lang(); +foreach(['date', 'mbstring', 'pcre'] as $extension) { + if(!extension_loaded($extension)) { + send_fatal_error(sprintf(_('The %s extension of PHP is required, please install it first.'), $extension)); + } +} +mb_internal_encoding('UTF-8'); check_db(); cron(); route(); @@ -4903,7 +4906,6 @@ function load_lang(): void function load_config(): void { - mb_internal_encoding('UTF-8'); define('VERSION', '1.24.1'); // Script version define('DBVERSION', 48); // Database layout version define('MSGENCRYPTED', false); // Store messages encrypted in the database to prevent other database users from reading them - true/false - visit the setup page after editing!