echo "        </table>\n";
     echo "      </td>\n";
     echo "    </tr>\n";
     echo "    <tr>\n";
     echo "      <td align=\"left\">&nbsp;</td>\n";
     echo "    </tr>\n";
     echo "    <tr>\n";
     echo "      <td colspan=\"2\" align=\"center\">", form_submit("editfilter_submit", gettext("Save")), "&nbsp;", form_submit("delete", gettext("Delete")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
     echo "    </tr>\n";
     echo "  </table>\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.")), '600', 'left');
     echo "</form>\n";
     html_draw_bottom();
 } else {
     html_draw_top(sprintf('title=%s', gettext("My Controls - Edit Word Filter")), 'class=window_title');
     $word_filter_array = user_get_word_filter_list($page);
     echo "<h1>", gettext("Edit Word Filter"), "</h1>\n";
     if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
         html_display_error_array($error_msg_array, '600', 'left');
     } else {
         if (isset($_GET['updated'])) {
             html_display_success_msg(gettext("Word Filter updated"), '600', 'left');
         } 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."), '600', 'left');
             }
         }
     }
     echo "<br />\n";
     echo "<form accept-charset=\"utf-8\" method=\"post\" action=\"edit_wordfilter.php\">\n";
     echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
Example #2
0
function user_get_word_filter_list($page)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($page)) {
        $page = 1;
    }
    $offset = calculate_page_offset($page, 10);
    $word_filter_array = array();
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    $sql = "SELECT SQL_CALC_FOUND_ROWS FID, FILTER_NAME, MATCH_TEXT, ";
    $sql .= "REPLACE_TEXT, FILTER_TYPE, FILTER_ENABLED ";
    $sql .= "FROM `{$table_prefix}WORD_FILTER` ";
    $sql .= "WHERE UID = '{$_SESSION['UID']}' 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 user_get_word_filter_list($page - 1);
    }
    while (($word_filter_data = $result->fetch_assoc()) !== null) {
        $word_filter_array[$word_filter_data['FID']] = $word_filter_data;
    }
    return array('word_filter_count' => $word_filter_count, 'word_filter_array' => $word_filter_array);
}