diff --git a/CHANGELOG b/CHANGELOG
index 847e97f..5fe0a6a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@ Use constants for configuration
Simplify extreme captcha code generation
Add language setting to profile
Add checks for required extensions
+Move some more settings to the database
+Add CSS to limit list of chatters hight
Version 1.15.3 - Mar. 6, 2016
Allow using html tags in linkfilter without breaking dereferrer or image embed
diff --git a/chat.php b/chat.php
index 8ba7c0e..9604c21 100644
--- a/chat.php
+++ b/chat.php
@@ -203,12 +203,12 @@ if(!isSet($_REQUEST['action'])){
if(!valid_admin()){
send_alogin();
}
- $C['bool_settings']=array('suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'incognito', 'enablejs');
+ $C['bool_settings']=array('suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'incognito', 'enablejs', 'sendmail');
$C['colour_settings']=array('colbg', 'coltxt');
$C['msg_settings']=array('msgenter', 'msgexit', 'msgmemreg', 'msgsureg', 'msgkick', 'msgmultikick', 'msgallkick', 'msgclean', 'msgsendall', 'msgsendmem', 'msgsendmod', 'msgsendadm', 'msgsendprv');
- $C['number_settings']=array('memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'numnotes');
+ $C['number_settings']=array('memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'keeplimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'numnotes');
$C['textarea_settings']=array('rulestxt', 'css');
- $C['text_settings']=array('dateformat', 'captchachars', 'redirect', 'chatname');
+ $C['text_settings']=array('dateformat', 'captchachars', 'redirect', 'chatname', 'mailsender', 'mailreceiver');
$C['settings']=array_merge(array('guestaccess', 'englobalpass', 'globalpass', 'captcha', 'dismemcaptcha', 'topic'), $C['bool_settings'], $C['colour_settings'], $C['msg_settings'], $C['number_settings'], $C['textarea_settings'], $C['text_settings']); // All settings in the database
if(empty($_REQUEST['do'])){
}elseif($_REQUEST['do']==='save'){
@@ -1256,7 +1256,7 @@ function send_messages($js){
echo '';
echo '
';
echo get_setting('topic');
- echo '
';
+ echo '
';
print_chatters();
echo "
$I[bottom]";
print_messages();
@@ -2752,17 +2752,17 @@ function write_message($message){
}
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'messages (postdate, poststatus, poster, recipient, text, delstatus) VALUES (?, ?, ?, ?, ?, ?);');
$stmt->execute(array($message['postdate'], $message['poststatus'], $message['poster'], $message['recipient'], $message['text'], $message['delstatus']));
- $limit=KEEPLIMIT*get_setting('messagelimit');
+ $limit=get_setting('keeplimit')*get_setting('messagelimit');
$stmt=$db->query('SELECT id FROM ' . PREFIX . "messages ORDER BY id DESC LIMIT 1 OFFSET $limit");
if($id=$stmt->fetch(PDO::FETCH_NUM)){
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'messages WHERE id<=?;');
$stmt->execute(array($id[0]));
}
- if(SENDMAIL && $message['poststatus']<9){
+ if($message['poststatus']<9 && get_setting('sendmail')){
$subject='New Chat message';
- $headers='From: ' . MAILSENDER . "\r\nX-Mailer: PHP/".phpversion()."\r\nContent-Type: text/html; charset=UTF-8\r\n";
+ $headers='From: '.get_setting('mailsender')."\r\nX-Mailer: PHP/".phpversion()."\r\nContent-Type: text/html; charset=UTF-8\r\n";
$body='$message[text]";
- mail(MAILRECEIVER, $subject, $body, $headers);
+ mail(get_setting('mailreceiver'), $subject, $body, $headers);
}
}
@@ -3117,7 +3117,7 @@ function init_chat(){
$db->exec('CREATE INDEX IF NOT EXISTS lastpost ON ' . PREFIX . 'sessions (lastpost);');
$db->exec('CREATE TABLE IF NOT EXISTS ' . PREFIX . "settings (setting TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL);");
}
- $settings=array(array('guestaccess', '0'), array('globalpass', ''), array('englobalpass', '0'), array('captcha', '0'), array('dateformat', 'm-d H:i:s'), array('rulestxt', ''), array('msgencrypted', '0'), array('dbversion', DBVERSION), array('css', 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} input,select,textarea{color:#FFFFFF;background-color:#000000;} a img{width:15%} a:hover img{width:35%} .error{color:#FF0033;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;}'), array('memberexpire', '60'), array('guestexpire', '15'), array('kickpenalty', '10'), array('entrywait', '120'), array('messageexpire', '14400'), array('messagelimit', '150'), array('maxmessage', 2000), array('captchatime', '600'), array('colbg', '000000'), array('coltxt', 'FFFFFF'), array('maxname', '20'), array('minpass', '5'), array('defaultrefresh', '20'), array('dismemcaptcha', '0'), array('suguests', '0'), array('imgembed', '1'), array('timestamps', '1'), array('trackip', '0'), array('captchachars', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), array('memkick', '1'), array('forceredirect', '0'), array('redirect', ''), array('incognito', '1'), array('enablejs', '0'), array('chatname', 'My Chat'), array('topic', ''), array('msgsendall', $I['sendallmsg']), array('msgsendmem', $I['sendmemmsg']), array('msgsendmod', $I['sendmodmsg']), array('msgsendadm', $I['sendadmmsg']), array('msgsendprv', $I['sendprvmsg']), array('msgenter', $I['entermsg']), array('msgexit', $I['exitmsg']), array('msgmemreg', $I['memregmsg']), array('msgsureg', $I['suregmsg']), array('msgkick', $I['kickmsg']), array('msgmultikick', $I['multikickmsg']), array('msgallkick', $I['allkickmsg']), array('msgclean', $I['cleanmsg']), array('numnotes', '3'));
+ $settings=array(array('guestaccess', '0'), array('globalpass', ''), array('englobalpass', '0'), array('captcha', '0'), array('dateformat', 'm-d H:i:s'), array('rulestxt', ''), array('msgencrypted', '0'), array('dbversion', DBVERSION), array('css', 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} input,select,textarea{color:#FFFFFF;background-color:#000000;} a img{width:15%} a:hover img{width:35%} .error{color:#FF0033;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;}'), array('memberexpire', '60'), array('guestexpire', '15'), array('kickpenalty', '10'), array('entrywait', '120'), array('messageexpire', '14400'), array('messagelimit', '150'), array('maxmessage', 2000), array('captchatime', '600'), array('colbg', '000000'), array('coltxt', 'FFFFFF'), array('maxname', '20'), array('minpass', '5'), array('defaultrefresh', '20'), array('dismemcaptcha', '0'), array('suguests', '0'), array('imgembed', '1'), array('timestamps', '1'), array('trackip', '0'), array('captchachars', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), array('memkick', '1'), array('forceredirect', '0'), array('redirect', ''), array('incognito', '1'), array('enablejs', '0'), array('chatname', 'My Chat'), array('topic', ''), array('msgsendall', $I['sendallmsg']), array('msgsendmem', $I['sendmemmsg']), array('msgsendmod', $I['sendmodmsg']), array('msgsendadm', $I['sendadmmsg']), array('msgsendprv', $I['sendprvmsg']), array('msgenter', $I['entermsg']), array('msgexit', $I['exitmsg']), array('msgmemreg', $I['memregmsg']), array('msgsureg', $I['suregmsg']), array('msgkick', $I['kickmsg']), array('msgmultikick', $I['multikickmsg']), array('msgallkick', $I['allkickmsg']), array('msgclean', $I['cleanmsg']), array('numnotes', '3'), array('keeplimit', '3'), array('mailsender', 'www-data '), array('mailreceiver', 'Webmaster '), array('sendmail', '0'));
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'settings (setting, value) VALUES (?, ?);');
foreach($settings as $pair){
$stmt->execute($pair);
@@ -3244,6 +3244,9 @@ function update_db(){
$db->exec('CREATE TABLE IF NOT EXISTS ' . PREFIX . 'captcha (id int(10) unsigned NOT NULL AUTO_INCREMENT, time int(10) unsigned NOT NULL, code char(5) NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;');
}
}
+ if($dbversion<15){
+ $db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('keeplimit', '3'), ('mailsender', 'www-data '), ('mailreceiver', 'Webmaster '), ('sendmail', '0');");
+ }
update_setting('dbversion', DBVERSION);
if(get_setting('msgencrypted')!=MSGENCRYPTED){
if(!extension_loaded('openssl')){
@@ -3403,8 +3406,7 @@ function load_lang(){
function load_config(){
define('VERSION', '1.15.3'); // Script version
- define('DBVERSION', 14); // Database version
- define('KEEPLIMIT', 3); // Amount of messages to keep in the database (multiplied with max messages displayed) - increase if you have many private messages
+ define('DBVERSION', 15); // Database 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('ENCRYPTKEY', 'MY_KEY'); // Encryption key for messages
define('DBHOST', 'localhost'); // Database host
@@ -3414,13 +3416,14 @@ function load_config(){
define('PERSISTENT', true); // Use persistent database conection true/false
define('PREFIX', ''); // Prefix - Set this to a unique value for every chat, if you have more than 1 chats on the same database or domain - use only alpha-numeric values (A-Z, a-z, 0-9, or _) other symbols might break the queries
define('MEMCACHED', false); // Enable/disable memcached caching true/false - needs memcached extension and a memcached server.
- define('MEMCACHEDHOST', 'localhost'); // Memcached host
- define('MEMCACHEDPORT', '11211'); // Memcached port
- define('SENDMAIL', false); // Send mail on new message - only activate on low traffic chat or your inbox will fill up very fast!
- define('MAILSENDER', 'www-data '); // Send mail using this e-Mail address
- define('MAILRECEIVER', 'Webmaster '); // Send mail to this e-Mail address
+ if(MEMCACHED){
+ define('MEMCACHEDHOST', 'localhost'); // Memcached host
+ define('MEMCACHEDPORT', '11211'); // Memcached port
+ }
define('DBDRIVER', 0); // Selects the database driver to use - 0=MySQL, 1=PostgreSQL, 2=sqlite
- define('SQLITEDBFILE', 'public_chat.sqlite'); // Filepath of the sqlite database, if sqlite is used - make sure it is writable for the webserver user
+ if(DBDRIVER===2){
+ define('SQLITEDBFILE', 'public_chat.sqlite'); // Filepath of the sqlite database, if sqlite is used - make sure it is writable for the webserver user
+ }
define('COOKIENAME', PREFIX . 'chat_session'); // Cookie name storing the session information
define('LANG', 'en'); // Default language
}
diff --git a/lang_de.php b/lang_de.php
index 6cc46b9..c3bdf43 100644
--- a/lang_de.php
+++ b/lang_de.php
@@ -254,6 +254,7 @@ $T=array(
'captchatime' => 'Captcha-Ablaufzeit (Sekunden)',
'messageexpire' => 'Nachrichten-Ablaufzeit (Minuten)',
'messagelimit' => 'Nachrichtenlimit (öffentliche)',
+ 'keeplimit' => 'So viele Male zusätzliche Nachrichten behalten (PMs und Mitgliederchat)',
'maxmessage' => 'Maximale Nachrichenlänge',
'confirm' => 'Bist du sicher?',
'yes' => 'Ja',
@@ -319,5 +320,8 @@ $T=array(
'pdo_pgsqlextrequired' => 'Die pdo_pgsql Erweiterung von PHP wird für den ausgewählten Datenbanktreiber benötigt. Bitte installieren Sie diese zuerst.',
'pdo_sqliteextrequired' => 'Die pdo_sqlite Erweiterung von PHP wird für den ausgewählten Datenbanktreiber benötigt. Bitte installieren Sie diese zuerst.',
'jsonextrequired' => 'Für diese Funktion wird die json Erweiterung von PHP benötigt. Bitte installieren Sie diese zuerst.',
+ 'sendmail' => 'E-Mail bei neuer Nachricht senden',
+ 'mailsender' => 'E-Mail mit dieser Adresse versenden',
+ 'mailreceiver' => 'E-Mail and diese Adresse senden'
);
?>
diff --git a/lang_en.php b/lang_en.php
index 913f15f..69aba5f 100644
--- a/lang_en.php
+++ b/lang_en.php
@@ -254,6 +254,7 @@ $I=array(
'captchatime' => 'Captcha timeout (seconds)',
'messageexpire' => 'Message timeout (minutes)',
'messagelimit' => 'Message limit (public)',
+ 'keeplimit' => 'Keep this times additional messages (PMs and Member chat)',
'maxmessage' => 'Maximal message length',
'confirm' => 'Are you sure?',
'yes' => 'Yes',
@@ -318,6 +319,9 @@ $I=array(
'pdo_mysqlextrequired' => 'The pdo_mysql extension of PHP is required for the selected database driver. Please install it first.',
'pdo_pgsqlextrequired' => 'The pdo_pgsql extension of PHP is required for the selected database driver. Please install it first.',
'pdo_sqliteextrequired' => 'The pdo_sqlite extension of PHP is required for the selected database driver. Please install it first.',
- 'jsonextrequired' => 'The json extension of PHP is required for this feature. Please install it first.'
+ 'jsonextrequired' => 'The json extension of PHP is required for this feature. Please install it first.',
+ 'sendmail' => 'Send mail on new public message',
+ 'mailsender' => 'Send mail using this address',
+ 'mailreceiver' => 'Send mail to this address'
);
?>