function show_bad_words() { $list = bad_word_list(); if ($list !== FALSE) { foreach ($list as $bad_word) { ?> <p> <input type="checkbox" name="id[]" value="<?php echo htmlspecialchars_default($bad_word); ?> " /> <?php echo htmlspecialchars_default($bad_word); ?> </p> <?php } } }
function remove_bad_word($wordArray) { // Remove bad_words by id $bad_words = bad_word_list(); if ($bad_words !== FALSE) { // Remove words from bad word list foreach ($wordArray as $word) { $idx = array_search(trim($word), $bad_words); if ($idx !== FALSE) { unset($bad_words[$idx]); } else { die("An invalid bad word was specified."); } } // Create flat data for file $raw_bad_words_flat = implode("\n", $bad_words); if (!empty($raw_bad_words_flat)) { $raw_bad_words_flat .= "\n"; } // Rewrite data to file $bad_word_fp = @fopen(bad_word_file_path(), "w"); if ($bad_word_fp === FALSE) { die("Unable to open bad word file for writing."); } @flock($bad_word_fp, LOCK_EX); fputs($bad_word_fp, $raw_bad_words_flat); @flock($bad_word_fp, LOCK_UN); @fclose($bad_word_fp); } else { die("Unable to get list of current bad words."); } }