Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: cleanWords code - 1.5.31  (Read 2117 times)

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
cleanWords code - 1.5.31
« on: February 06, 2007, 11:26:21 pm »

Code: [Select]
// CLEAN - WORD FILTER
function cleanWords($text) {
if ((strtolower(s('word_filter_enable')) == 'on') && (file_exists(s('word_filter_file')))) {
$bad_words_to_what = s('word_filter_change');
$text = preg_replace($bad_words_from_what, $bad_words_to_what, $text);
return $text;
} else {return $text;}
}
Within this code - variable $bad_words_from_what is only used, but not initialized. Looks like a bug :D
« Last Edit: September 24, 2007, 11:53:19 am by codetwist »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
cleanWords code - 1.5.31
« Reply #1 on: February 07, 2007, 03:23:30 pm »

It would appear that two strings - which are in the 1.5.30 snews.php file (in this function) have been removed for some reason, as noted here in blue:
Quote
From snews.php, 1.5.30 version:
// CLEAN - WORD FILTER
function cleanWords($text) {
   if ((strtolower(s('word_filter_enable')) == 'on') && (file_exists(s('word_filter_file')))) {
      $bad_words_from_what = preg_replace('/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/', '', file(s('word_filter_file')));
      $bad_words_from_what = preg_replace('/^(.*)$/', '/\\1/i', $bad_words_from_what);

      $bad_words_to_what = s('word_filter_change');
      $text = preg_replace($bad_words_from_what, $bad_words_to_what, $text);
      return $text;
   } else {return $text;}
}
Mika - Luka - any reason as to why they are removed in 1.5.31?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU