Compare commits
4 Commits
f1f991ae6c
...
master
Author | SHA1 | Date | |
---|---|---|---|
b8eeda6023
|
|||
39e3018222
|
|||
5243ef0e94
|
|||
0f7006275c
|
@ -38,11 +38,12 @@ Features:
|
|||||||
Installation Instructions:
|
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.
|
You will also need the pdo_sqlite, pdo_mysql or pdo_pgsql extension, depending on which database you choose.
|
||||||
Optionally, you can install:
|
Optionally, you can install:
|
||||||
- the gd extension for the captcha feature
|
- the gd extension for the captcha feature
|
||||||
- the json extension for save/restore
|
- 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 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
|
- 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
|
- the libsodium extension (PHP >= 7.2) for encryption of messages and notes in the database
|
||||||
|
36
chat.php
36
chat.php
@ -32,6 +32,16 @@
|
|||||||
* 9 - Private messages
|
* 9 - Private messages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!extension_loaded('gettext')) {
|
||||||
|
prepare_stylesheets('fatal_error');
|
||||||
|
send_headers();
|
||||||
|
echo '<!DOCTYPE html><html lang="en" dir="ltr"><head>'.meta_html();
|
||||||
|
echo '<title>Fatal error</title>';
|
||||||
|
echo "<style>$styles[fatal_error]</style>";
|
||||||
|
echo '</head><body>';
|
||||||
|
echo '<h2>Fatal error: The gettext extension of PHP is required, please install it first.</h2>';
|
||||||
|
print_end();
|
||||||
|
}
|
||||||
// initialize and load variables/configuration
|
// initialize and load variables/configuration
|
||||||
const LANGUAGES = [
|
const LANGUAGES = [
|
||||||
'ar' => ['name' => 'العربية', 'locale' => 'ar', 'dir' => 'rtl'],
|
'ar' => ['name' => 'العربية', 'locale' => 'ar', 'dir' => 'rtl'],
|
||||||
@ -69,18 +79,13 @@ if(!isset($_REQUEST['session']) && isset($_COOKIE[COOKIENAME])){
|
|||||||
$session = $_COOKIE[COOKIENAME];
|
$session = $_COOKIE[COOKIENAME];
|
||||||
}
|
}
|
||||||
$session = preg_replace('/[^0-9a-zA-Z]/', '', $session);
|
$session = preg_replace('/[^0-9a-zA-Z]/', '', $session);
|
||||||
if (!extension_loaded('gettext')) {
|
|
||||||
prepare_stylesheets('fatal_error');
|
|
||||||
send_headers();
|
|
||||||
echo '<!DOCTYPE html><html lang="en" dir="ltr"><head>'.meta_html();
|
|
||||||
echo '<title>Fatal error</title>';
|
|
||||||
echo "<style>$styles[fatal_error]</style>";
|
|
||||||
echo '</head><body>';
|
|
||||||
echo '<h2>Fatal error: The gettext extension of PHP is required, please install it first</h2>';
|
|
||||||
print_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
load_lang();
|
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();
|
check_db();
|
||||||
cron();
|
cron();
|
||||||
route();
|
route();
|
||||||
@ -4422,7 +4427,7 @@ function update_db(): void
|
|||||||
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('css', ''), ('memberexpire', '60'), ('guestexpire', '15'), ('kickpenalty', '10'), ('entrywait', '120'), ('messageexpire', '14400'), ('messagelimit', '150'), ('maxmessage', 2000), ('captchatime', '600');");
|
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('css', ''), ('memberexpire', '60'), ('guestexpire', '15'), ('kickpenalty', '10'), ('entrywait', '120'), ('messageexpire', '14400'), ('messagelimit', '150'), ('maxmessage', 2000), ('captchatime', '600');");
|
||||||
}
|
}
|
||||||
if($dbversion<11){
|
if($dbversion<11){
|
||||||
$db->exec('ALTER TABLE ' , PREFIX . 'captcha CHARACTER SET utf8 COLLATE utf8_bin;');
|
$db->exec('ALTER TABLE ' . PREFIX . 'captcha CHARACTER SET utf8 COLLATE utf8_bin;');
|
||||||
$db->exec('ALTER TABLE ' . PREFIX . 'filter CHARACTER SET utf8 COLLATE utf8_bin;');
|
$db->exec('ALTER TABLE ' . PREFIX . 'filter CHARACTER SET utf8 COLLATE utf8_bin;');
|
||||||
$db->exec('ALTER TABLE ' . PREFIX . 'ignored CHARACTER SET utf8 COLLATE utf8_bin;');
|
$db->exec('ALTER TABLE ' . PREFIX . 'ignored CHARACTER SET utf8 COLLATE utf8_bin;');
|
||||||
$db->exec('ALTER TABLE ' . PREFIX . 'messages CHARACTER SET utf8 COLLATE utf8_bin;');
|
$db->exec('ALTER TABLE ' . PREFIX . 'messages CHARACTER SET utf8 COLLATE utf8_bin;');
|
||||||
@ -4458,7 +4463,7 @@ function update_db(): void
|
|||||||
$db->exec('ALTER TABLE ' . PREFIX . 'notes MODIFY type char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY editedby varchar(50) NOT NULL, MODIFY text varchar(20000) NOT NULL;');
|
$db->exec('ALTER TABLE ' . PREFIX . 'notes MODIFY type char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY editedby varchar(50) NOT NULL, MODIFY text varchar(20000) NOT NULL;');
|
||||||
$db->exec('ALTER TABLE ' . PREFIX . 'settings MODIFY id integer unsigned NOT NULL, MODIFY setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY value varchar(20000) NOT NULL;');
|
$db->exec('ALTER TABLE ' . PREFIX . 'settings MODIFY id integer unsigned NOT NULL, MODIFY setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, MODIFY value varchar(20000) NOT NULL;');
|
||||||
$db->exec('ALTER TABLE ' . PREFIX . 'settings DROP PRIMARY KEY, DROP id, ADD PRIMARY KEY(setting);');
|
$db->exec('ALTER TABLE ' . PREFIX . 'settings DROP PRIMARY KEY, DROP id, ADD PRIMARY KEY(setting);');
|
||||||
$stmt = $db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('chatname', 'My Chat'), ('topic', ''), ('msgsendall', ?), ('msgsendmem', ?), ('msgsendmod', ?), ('msgsendadm', ?), ('msgsendprv', ?), ('numnotes', '3');");
|
$stmt = $db->prepare('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('chatname', 'My Chat'), ('topic', ''), ('msgsendall', ?), ('msgsendmem', ?), ('msgsendmod', ?), ('msgsendadm', ?), ('msgsendprv', ?), ('numnotes', '3');");
|
||||||
$stmt->execute([_('%s - '), _('[M] %s - '), _('[Staff] %s - '), _('[Admin] %s - '), _('[%1$s to %2$s] - ')]);
|
$stmt->execute([_('%s - '), _('[M] %s - '), _('[Staff] %s - '), _('[Admin] %s - '), _('[%1$s to %2$s] - ')]);
|
||||||
}
|
}
|
||||||
if($dbversion<13){
|
if($dbversion<13){
|
||||||
@ -4892,7 +4897,9 @@ function load_lang(): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
putenv('LC_ALL='.$locale);
|
if(function_exists('putenv')) {
|
||||||
|
putenv('LC_ALL='.$locale);
|
||||||
|
}
|
||||||
setlocale(LC_ALL, $locale);
|
setlocale(LC_ALL, $locale);
|
||||||
bindtextdomain('le-chat-php', __DIR__.'/locale');
|
bindtextdomain('le-chat-php', __DIR__.'/locale');
|
||||||
bind_textdomain_codeset('le-chat-php', 'UTF-8');
|
bind_textdomain_codeset('le-chat-php', 'UTF-8');
|
||||||
@ -4901,7 +4908,6 @@ function load_lang(): void
|
|||||||
|
|
||||||
function load_config(): void
|
function load_config(): void
|
||||||
{
|
{
|
||||||
mb_internal_encoding('UTF-8');
|
|
||||||
define('VERSION', '1.24.1'); // Script version
|
define('VERSION', '1.24.1'); // Script version
|
||||||
define('DBVERSION', 48); // Database layout 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!
|
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!
|
||||||
|
Reference in New Issue
Block a user