echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td colspan=\"2\" align=\"center\">", form_submit("editfilter_submit", gettext("Save")), " ", form_submit("delete", gettext("Delete")), " ", form_submit("cancel", gettext("Cancel")), "</td>\n"; echo " </tr>\n"; echo " </table>\n"; echo "</form>\n"; html_display_warning_msg(sprintf('%s<p>%s</p>%s', gettext("<b>All</b> matches against the whole text so filtering mom to mum will also change moment to mument."), gettext("<b>Whole Word</b> matches against whole words only so filtering mom to mum will NOT change moment to mument."), gettext("<b>PREG</b> allows you to use Perl Regular Expressions to match text.")), '700', 'center'); echo "</div>\n"; html_draw_bottom(); } else { html_draw_top(array('title' => gettext('Admin - Word Filter'), 'class' => 'window_title', 'main_css' => 'admin.css')); $word_filter_array = admin_get_word_filter_list($page); echo "<h1>", gettext("Admin"), html_style_image('separator'), gettext("Word Filter"), "</h1>\n"; if (isset($error_msg_array) && sizeof($error_msg_array) > 0) { html_display_error_array($error_msg_array, '86%', 'center'); } else { if (isset($_GET['updated'])) { html_display_success_msg(gettext("Word Filter updated"), '86%', 'center'); } else { if (sizeof($word_filter_array['word_filter_array']) < 1) { html_display_warning_msg(gettext("No existing word filter entries found. To add a filter click the 'Add New' button below."), '86%', 'center'); } } } echo "<br />\n"; echo "<div align=\"center\">\n"; echo "<form accept-charset=\"utf-8\" method=\"post\" action=\"admin_wordfilter.php\">\n";
function admin_get_word_filter_list($page = 1) { if (!($db = db::get())) { return false; } if (!is_numeric($page) || $page < 1) { $page = 1; } $offset = calculate_page_offset($page, 10); $word_filter_array = array(); if (!($table_prefix = get_table_prefix())) { return false; } $sql = "SELECT SQL_CALC_FOUND_ROWS FID, FILTER_NAME, MATCH_TEXT, REPLACE_TEXT, "; $sql .= "FILTER_TYPE, FILTER_ENABLED FROM `{$table_prefix}WORD_FILTER` "; $sql .= "WHERE UID = 0 ORDER BY FID "; $sql .= "LIMIT {$offset}, 10"; if (!($result = $db->query($sql))) { return false; } $sql = "SELECT FOUND_ROWS() AS ROW_COUNT"; if (!($result_count = $db->query($sql))) { return false; } list($word_filter_count) = $result_count->fetch_row(); if ($result->num_rows == 0 && $word_filter_count > 0 && $page > 1) { return admin_get_word_filter_list($page - 1); } while ($word_filter_data = $result->fetch_assoc()) { $word_filter_array[$word_filter_data['FID']] = $word_filter_data; } return array('word_filter_count' => $word_filter_count, 'word_filter_array' => $word_filter_array); }