Beispiel #1
0
}
if (isset($_POST['fid']) && is_numeric($_POST['fid'])) {
    $search_folder_fid = $_POST['fid'];
} else {
    $search_folder_fid = 0;
}
$search_date_from_array = array(SEARCH_FROM_TODAY => gettext("Today"), SEARCH_FROM_YESTERDAY => gettext("Yesterday"), SEARCH_FROM_DAYBEFORE => gettext("Day before yesterday"), SEARCH_FROM_ONE_WEEK_AGO => sprintf(gettext("%s week ago"), 1), SEARCH_FROM_TWO_WEEKS_AGO => sprintf(gettext("%s weeks ago"), 2), SEARCH_FROM_THREE_WEEKS_AGO => sprintf(gettext("%s weeks ago"), 3), SEARCH_FROM_ONE_MONTH_AGO => sprintf(gettext("%s month ago"), 1), SEARCH_FROM_TWO_MONTHS_AGO => sprintf(gettext("%s months ago"), 2), SEARCH_FROM_THREE_MONTHS_AGO => sprintf(gettext("%s months ago"), 3), SEARCH_FROM_SIX_MONTHS_AGO => sprintf(gettext("%s months ago"), 6), SEARCH_FROM_ONE_YEAR_AGO => sprintf(gettext("%s year ago"), 1), SEARCH_FROM_BEGINNING_OF_TIME => gettext("Beginning of time"));
$search_date_to_array = array(SEARCH_TO_NOW => gettext("Now"), SEARCH_TO_TODAY => gettext("Today"), SEARCH_TO_YESTERDAY => gettext("Yesterday"), SEARCH_TO_DAYBEFORE => gettext("Day before yesterday"), SEARCH_TO_ONE_WEEK_AGO => sprintf(gettext("%s week ago"), 1), SEARCH_TO_TWO_WEEKS_AGO => sprintf(gettext("%s weeks ago"), 2), SEARCH_TO_THREE_WEEKS_AGO => sprintf(gettext("%s weeks ago"), 3), SEARCH_TO_ONE_MONTH_AGO => sprintf(gettext("%s month ago"), 1), SEARCH_TO_TWO_MONTHS_AGO => sprintf(gettext("%s months ago"), 2), SEARCH_TO_THREE_MONTHS_AGO => sprintf(gettext("%s months ago"), 3), SEARCH_TO_SIX_MONTHS_AGO => sprintf(gettext("%s months ago"), 6), SEARCH_TO_ONE_YEAR_AGO => sprintf(gettext("%s year ago"), 1));
$search_sort_by_array = array(SEARCH_SORT_CREATED => gettext("Last post date"), SEARCH_SORT_NUM_REPLIES => gettext("Number of replies"), SEARCH_SORT_FOLDER_NAME => gettext("Folder name"), SEARCH_SORT_AUTHOR_NAME => gettext("Author name"), SEARCH_SORT_RELEVANCE => gettext("Relevancy"));
$search_sort_dir_array = array(SEARCH_SORT_ASC => gettext("Oldest first"), SEARCH_SORT_DESC => gettext("Newest first"));
if (!($folder_dropdown = folder_search_dropdown($search_folder_fid))) {
    html_draw_error(gettext("There are no folders available."));
}
$min_length = 4;
$max_length = 84;
search_get_word_lengths($min_length, $max_length);
if ((isset($_POST) && sizeof($_POST) > 0 && !isset($_POST['search_reset']) || isset($_GET['search_string']) || isset($_GET['logon']) || isset($_GET['tag'])) && !isset($_GET['search_error'])) {
    $page = 1;
    $search_arguments = array();
    $search_no_matches = false;
    if (isset($_GET['search_string']) && strlen(trim($_GET['search_string'])) > 0) {
        $search_arguments['search_string'] = trim($_GET['search_string']);
    } else {
        if (isset($_GET['tag']) && strlen(trim($_GET['tag'])) > 0) {
            $search_arguments['search_tag'] = trim($_GET['tag']);
        } else {
            if (isset($_POST['search_string']) && strlen(trim($_POST['search_string'])) > 0) {
                $search_arguments['search_string'] = trim($_POST['search_string']);
            }
        }
    }
Beispiel #2
0
function search_strip_special_chars($keywords_array, $remove_non_matches = true)
{
    if (!is_array($keywords_array)) {
        return false;
    }
    if (!is_bool($remove_non_matches)) {
        $remove_non_matches = true;
    }
    // Get the min and max word lengths that MySQL supports
    $min_length = 4;
    $max_length = 84;
    search_get_word_lengths($min_length, $max_length);
    // Expression to match words prefixed with a hyphen (for do not match)
    if ($remove_non_matches === true) {
        $boolean_non_match = sprintf('/^-["]?([\\pL\\pN\\pP\\pZ]){%d,%d}["]?$/Du', $min_length, $max_length);
        $keywords_array = preg_grep($boolean_non_match, $keywords_array, PREG_GREP_INVERT);
        $keywords_array = preg_replace('/["|\\+|\\x00]+/u', '', $keywords_array);
    } else {
        $keywords_array = preg_replace('/["|\\+|\\-|\\x00]+/u', '', $keywords_array);
    }
    // return array
    return $keywords_array;
}