Allow disabling applying of kick filters on moderators

This commit is contained in:
Daniel Winzen
2016-12-25 10:37:04 +01:00
parent 0e82276697
commit 8dd81ed766
4 changed files with 346 additions and 350 deletions

View File

@ -1,3 +1,4 @@
Version 1.23 - Dec. 25, 2016
Optimizations
More secure session key generation and password storage
Add option to make your own font small
@ -5,6 +6,7 @@ Separate changing nickname and password
Use PHPs native timezones
Add message asking for manual refresh, when it stopped working
Add personal notes
Allow disabling applying of kick filters on moderators
Version 1.22.1 - Nov. 13, 2016
Performance optimizations

View File

@ -57,6 +57,7 @@ route();
function route(){
global $U;
if(!isset($_REQUEST['action'])){
update_db();
send_login();
}elseif($_REQUEST['action']==='view'){
check_session();
@ -228,7 +229,7 @@ function route_setup(){
if(!valid_admin()){
send_alogin();
}
$C['bool_settings']=['suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'incognito', 'sendmail', 'modfallback', 'disablepm', 'eninbox', 'enablegreeting', 'sortupdown', 'hidechatters', 'enfileupload'];
$C['bool_settings']=['suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'incognito', 'sendmail', 'modfallback', 'disablepm', 'eninbox', 'enablegreeting', 'sortupdown', 'hidechatters', 'enfileupload', 'personalnotes', 'filtermodkick'];
$C['colour_settings']=['colbg', 'coltxt'];
$C['msg_settings']=['msgenter', 'msgexit', 'msgmemreg', 'msgsureg', 'msgkick', 'msgmultikick', 'msgallkick', 'msgclean', 'msgsendall', 'msgsendmem', 'msgsendmod', 'msgsendadm', 'msgsendprv', 'msgattache'];
$C['number_settings']=['memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'numnotes', 'maxuploadsize'];
@ -805,6 +806,9 @@ function send_backup($C){
if(isset($_REQUEST['notes'])){
$result=$db->query('SELECT * FROM ' . PREFIX . "notes;");
while($note=$result->fetch(PDO::FETCH_ASSOC)){
if(MSGENCRYPTED){
$note['text']=openssl_decrypt($note['text'], 'aes-256-cbc', ENCRYPTKEY, 0, '1234567890123456');
}
$code['notes'][]=$note;
}
}
@ -1492,11 +1496,6 @@ function send_inbox(){
}else{
$timestamps=false;
}
if(MSGENCRYPTED){
if(!extension_loaded('openssl')){
send_fatal_error($I['opensslextrequired']);
}
}
if($U['sortupdown']){
$direction='ASC';
}else{
@ -1543,9 +1542,6 @@ function send_notes($type){
}
if(isset($_REQUEST['text'])){
if(MSGENCRYPTED){
if(!extension_loaded('openssl')){
send_fatal_error($I['opensslextrequired']);
}
$_REQUEST['text']=openssl_encrypt($_REQUEST['text'], 'aes-256-cbc', ENCRYPTKEY, 0, '1234567890123456');
}
$time=time();
@ -1583,9 +1579,6 @@ function send_notes($type){
$stmt->execute([$U['nickname']]);
$settings=$stmt->fetch(PDO::FETCH_ASSOC);
if(MSGENCRYPTED){
if(!extension_loaded('openssl')){
send_fatal_error($I['opensslextrequired']);
}
$note['text']=openssl_decrypt($note['text'], 'aes-256-cbc', ENCRYPTKEY, 0, '1234567890123456');
}
echo "</p>".form('notes');
@ -2980,7 +2973,7 @@ function validate_input(){
}
function apply_filter($message, $poststatus, $nickname){
global $I;
global $I, $U;
$message=str_replace('<br>', "\n", $message);
$message=apply_mention($message);
$filters=get_filters();
@ -2992,7 +2985,7 @@ function apply_filter($message, $poststatus, $nickname){
$message=preg_replace("/$filter[match]/iu", $filter['replace'], $message, -1, $count);
}
}
if(isset($count) && $count>0 && $filter['kick']){
if(isset($count) && $count>0 && $filter['kick'] && ($U['status']<5 || get_setting('filtermodkick'))){
kick_chatter([$nickname], $filter['replace'], false);
setcookie(COOKIENAME, false);
$_REQUEST['session']='';
@ -3146,11 +3139,8 @@ function add_system_message($mes){
}
function write_message($message){
global $I, $db;
global $db;
if(MSGENCRYPTED){
if(!extension_loaded('openssl')){
send_fatal_error($I['opensslextrequired']);
}
$message['text']=openssl_encrypt($message['text'], 'aes-256-cbc', ENCRYPTKEY, 0, '1234567890123456');
}
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'messages (postdate, poststatus, poster, recipient, text, delstatus) VALUES (?, ?, ?, ?, ?, ?);');
@ -3218,7 +3208,7 @@ function del_last_message(){
}
function print_messages($delstatus=0){
global $I, $U, $db;
global $U, $db;
$dateformat=get_setting('dateformat');
if(!$U['embed'] && get_setting('imgembed')){
$removeEmbed=true;
@ -3230,11 +3220,6 @@ function print_messages($delstatus=0){
}else{
$timestamps=false;
}
if(MSGENCRYPTED){
if(!extension_loaded('openssl')){
send_fatal_error($I['opensslextrequired']);
}
}
if($U['sortupdown']){
$direction='ASC';
}else{
@ -3525,6 +3510,7 @@ function destroy_chat($C){
}
$memcached->delete(DBNAME . '-' . PREFIX . 'settings-dbversion');
$memcached->delete(DBNAME . '-' . PREFIX . 'settings-msgencrypted');
$memcached->delete(DBNAME . '-' . PREFIX . 'settings-nextcron');
}
echo "<h2>$I[destroyed]</h2><br><br><br>";
echo form('setup').submit($I['init']).'</form>'.credit();
@ -3685,6 +3671,7 @@ function init_chat(){
'eninbox' =>0,
'sortupdown' =>0,
'hidechatters' =>0,
'filtermodkick' =>1,
];
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'members (nickname, passhash, status, refresh, bgcolour, timestamps, style, embed, incognito, nocache, tz, eninbox, sortupdown, hidechatters, nocache_old) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);');
$stmt->execute([$reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['timestamps'], $reg['style'], $reg['embed'], $reg['incognito'], $reg['nocache'], $reg['tz'], $reg['eninbox'], $reg['sortupdown'], $reg['hidechatters'], $reg['nocache_old']]);
@ -3699,7 +3686,10 @@ function init_chat(){
function update_db(){
global $I, $db, $memcached;
$dbversion=(int) get_setting('dbversion');
if($dbversion<DBVERSION || get_setting('msgencrypted')!=MSGENCRYPTED){
$msgencrypted=(bool) get_setting('msgencrypted');
if($dbversion>=DBVERSION && $msgencrypted===MSGENCRYPTED){
return;
}
ignore_user_abort(true);
set_time_limit(0);
if(DBDRIVER===0){//MySQL
@ -4005,8 +3995,11 @@ function update_db(){
$db->exec('CREATE INDEX ' . PREFIX . 'notes_type ON ' . PREFIX . 'notes(type);');
$db->exec('CREATE INDEX ' . PREFIX . 'notes_editedby ON ' . PREFIX . 'notes(editedby);');
}
if($dbversion<40){
$db->exec('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('filtermodkick', '1');");
}
update_setting('dbversion', DBVERSION);
if(get_setting('msgencrypted')!=MSGENCRYPTED){
if($msgencrypted!==MSGENCRYPTED){
if(!extension_loaded('openssl')){
send_fatal_error($I['opensslextrequired']);
}
@ -4034,7 +4027,6 @@ function update_db(){
}
send_update($msg);
}
}
function get_setting($setting){
global $db, $memcached;
@ -4175,8 +4167,8 @@ function load_lang(){
function load_config(){
mb_internal_encoding('UTF-8');
define('VERSION', '1.22.1'); // Script version
define('DBVERSION', 39); // Database layout version
define('VERSION', '1.23'); // Script version
define('DBVERSION', 40); // 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('ENCRYPTKEY', 'MY_KEY'); // Encryption key for messages
define('DBHOST', 'localhost'); // Database host

View File

@ -368,5 +368,6 @@ $T=[
'cssupdate' => 'Hinweis: Standard CSS ist jetzt hardcoded und kann aus der CSS Einstellung entfernt werden',
'manualrefresh' => 'Manuelles Neuladen erforderlich',
'personalnotes' => 'Persönliche Notizen',
'filtermodkick' => 'Kickfilter auf Moderatoren anwenden',
];
?>

View File

@ -368,5 +368,6 @@ $I=[
'cssupdate' => 'Note: Default CSS is now hardcoded and can be removed from the CSS setting',
'manualrefresh' => 'Manual refresh required',
'personalnotes' => 'Personal notes',
'filtermodkick' => 'Apply kick filter on moderators',
];
?>