function search404_get_keys in Search 404 5
Same name and namespace in other branches
- 6 search404.module \search404_get_keys()
- 7 search404.page.inc \search404_get_keys()
Replacement for search_get_keys WARNING: This function can potentially return dangerous potential SQL inject/XSS data. Return must be sanatized before use.
1 call to search404_get_keys()
- search404_page in ./
search404.module - Main search function. Started with: http://drupal.org/node/12668 Updated to be more similar to search_view Beware of messy code
File
- ./
search404.module, line 37
Code
function search404_get_keys() {
// Abort query on certain extensions, e.g: gif jpg jpeg png
$extensions = preg_split('/\\s+/', variable_get('search404_ignore_query', 'gif jpg jpeg bmp png'));
$extensions = trim(implode('|', $extensions));
if (!empty($extensions) && preg_match("/\\.({$extensions})\$/", $_REQUEST['destination'])) {
return FALSE;
}
$keys = $_REQUEST['destination'];
$misc_var = variable_get('search404_regex', '');
if (!empty($misc_var)) {
$keys = preg_grep($misc_var, $keys);
$keys = $keys[0];
}
// Ingore certain extensions from query
$extensions = preg_split('/\\s+/', variable_get('search404_ignore_extensions', 'htm html php'));
$extensions = trim(implode('|', $extensions));
if (!empty($extensions)) {
$keys = preg_replace("/\\.({$extensions})\$/", '', $keys);
}
$keys = preg_split('/[' . PREG_CLASS_SEARCH_EXCLUDE . ']+/u', $keys);
// Ignore certain words
$keys = array_diff($keys, explode(' ', variable_get('search404_ignore', 'and or the')));
foreach ($keys as $a => $b) {
$keys[$a] = check_plain($b);
}
$modifier = variable_get('search404_use_or', FALSE) ? ' OR ' : ' ';
$keys = trim(implode($modifier, $keys));
return $keys;
}