if ($match != 'exact') { // $string will be cleaned below $string = str_replace(',', '', $_REQUEST['string']); } else { $string = (string) $_REQUEST['string']; } // redo possible magic quotes $string = $wb->strip_slashes($string); $string = preg_replace('/\\s+/', ' ', $string); $string = trim($string); // remove some bad chars $string = str_replace(array('[[', ']]'), '', $string); $string = preg_replace('/(^|\\s+)[|.]+(?=\\s+|$)/', '', $string); $search_display_string = htmlspecialchars($string); // convert string to utf-8 $string = entities_to_umlauts($string, 'UTF-8'); $search_url_string = $string; $search_entities_string = addslashes(htmlentities($string, ENT_COMPAT, 'UTF-8')); // mySQL needs four backslashes to match one in LIKE comparisons) $search_entities_string = str_replace('\\\\', '\\\\\\\\', $search_entities_string); $string = preg_quote($string); // quote ' " and / -we need quoted / for regex $search_normal_string = str_replace(array('\'', '"', '/'), array('\\\'', '\\"', '\\/'), $string); } // make arrays from the search_..._strings above if ($match == 'exact') { $search_url_array[] = $search_url_string; } else { $search_url_array = explode(' ', $search_url_string); } $search_normal_array = array();
/** * * @staticvar boolean $string_ul_umlaut * @staticvar boolean $string_ul_regex * @param string $foo * @param array $arr_string * @return string */ function search_highlight($foo = '', $arr_string = array()) { require_once WB_PATH . '/framework/functions.php'; static $string_ul_umlaut = FALSE; static $string_ul_regex = FALSE; if ($string_ul_umlaut === FALSE || $string_ul_regex === FALSE) { require WB_PATH . '/search/search_convert.php'; } $foo = entities_to_umlauts($foo, 'UTF-8'); array_walk($arr_string, create_function('&$v,$k', '$v = preg_quote($v, \'~\');')); $search_string = implode("|", $arr_string); $string = str_replace($string_ul_umlaut, $string_ul_regex, $search_string); // the highlighting // match $string, but not inside <style>...</style>, <script>...</script>, <!--...--> or HTML-Tags // Also droplet tags are now excluded from highlighting. // split $string into pieces - "cut away" styles, scripts, comments, HTML-tags and eMail-addresses // we have to cut <pre> and <code> as well. // for HTML-Tags use <(?:[^<]|<.*>)*> which will match strings like <input ... value="<b>value</b>" > $matches = preg_split("~(\\[\\[.*\\]\\]|<style.*</style>|<script.*</script>|<pre.*</pre>|<code.*</code>|<!--.*-->|<(?:[^<]|<.*>)*>|\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,8}\\b)~iUs", $foo, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if (is_array($matches) && $matches != array()) { $foo = ""; foreach ($matches as $match) { if ($match[0] != "<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,8}$/i', $match) && !preg_match('~\\[\\[.*\\]\\]~', $match)) { $match = str_replace(array('<', '>', '&', '"', ''', ' '), array('<', '>', '&', '"', '\'', " "), $match); $match = preg_replace('~(' . $string . ')~ui', '_span class=_highlight__$1_/span_', $match); $match = str_replace(array('&', '<', '>', '"', '\'', " "), array('&', '<', '>', '"', ''', ' '), $match); $match = str_replace(array('_span class=_highlight__', '_/span_'), array('<span class="highlight">', '</span>'), $match); } $foo .= $match; } } if (DEFAULT_CHARSET != 'utf-8') { $foo = umlauts_to_entities($foo, 'UTF-8'); } return $foo; }
// Initialize var $ship_address = ''; $email_ship_address = ''; // Check if the shipping address has been provided if (!empty($ship_first_name) && !empty($ship_last_name) && !empty($ship_street) && !empty($ship_zip) && !empty($ship_city) && !empty($ship_country)) { // Convert country code to country name $country_key = array_keys($MOD_BAKERY['TXT_COUNTRY_CODE'], $ship_country); $ship_country_name = $MOD_BAKERY['TXT_COUNTRY_NAME'][$country_key[0]]; // Convert country to uppercase if (function_exists('mb_strtoupper')) { $ship_country_name = mb_strtoupper(entities_to_umlauts($ship_country_name, $charset), $charset); } // Convert state code to state name if ($state_key = array_keys($MOD_BAKERY['TXT_STATE_CODE'], $ship_state)) { $ship_state = $MOD_BAKERY['TXT_STATE_NAME'][$state_key[0]]; $ship_state = entities_to_umlauts($ship_state, $charset); } // Join customer first and last name $ship_name = $ship_first_name . ' ' . $ship_last_name; // Prepare field shipping company if (empty($ship_company)) { $email_ship_company = ''; $ship_company = ''; } else { $email_ship_company = $ship_company . "\n\t"; $ship_company = $ship_company . '<br />'; } // Show address with state field if (!empty($ship_state)) { if ($setting_zip_location == 'end') { // Show zip at the end of address
function print_excerpt2($mod_vars, $func_vars) { extract($func_vars, EXTR_PREFIX_ALL, 'func'); extract($mod_vars, EXTR_PREFIX_ALL, 'mod'); global $TEXT; // check $mod_...vars if (!isset($mod_page_link)) { $mod_page_link = $func_page_link; } if (!isset($mod_page_link_target)) { $mod_page_link_target = ""; } if (!isset($mod_page_title)) { $mod_page_title = $func_page_title; } if (!isset($mod_page_description)) { $mod_page_description = $func_page_description; } if (!isset($mod_page_modified_when)) { $mod_page_modified_when = $func_page_modified_when; } if (!isset($mod_page_modified_by)) { $mod_page_modified_by = $func_page_modified_by; } if (!isset($mod_text)) { $mod_text = ""; } if (!isset($mod_max_excerpt_num)) { $mod_max_excerpt_num = $func_default_max_excerpt; } if (!isset($mod_pic_link)) { $mod_pic_link = ""; } if (!isset($mod_no_highlight)) { $mod_no_highlight = false; } if (!isset($func_enable_flush)) { $func_enable_flush = false; } // set this in db: wb_search.cfg_enable_flush [READ THE DOC BEFORE] if (isset($mod_ext_charset)) { $mod_ext_charset = strtolower($mod_ext_charset); } else { $mod_ext_charset = ''; } if ($mod_text == "") { return false; } if ($mod_no_highlight) { $mod_page_link_target = "&nohighlight=1" . $mod_page_link_target; } // clean the text: $mod_text = preg_replace('#<(br|dt|/dd|/?(?:h[1-6]|tr|table|p|li|ul|pre|code|div|hr))[^>]*>#i', '.', $mod_text); $mod_text = preg_replace('#<(!--.*--|style.*</style|script.*</script)>#iU', ' ', $mod_text); $mod_text = preg_replace('#\\[\\[.*?\\]\\]#', '', $mod_text); //Filter droplets from the page data // strip_tags() is called below if ($mod_ext_charset != '') { // data from external database may have a different charset require_once WB_PATH . '/framework/functions-utf8.php'; switch ($mod_ext_charset) { case 'latin1': case 'cp1252': $mod_text = charset_to_utf8($mod_text, 'CP1252'); break; case 'cp1251': $mod_text = charset_to_utf8($mod_text, 'CP1251'); break; case 'latin2': $mod_text = charset_to_utf8($mod_text, 'ISO-8859-2'); break; case 'hebrew': $mod_text = charset_to_utf8($mod_text, 'ISO-8859-8'); break; case 'greek': $mod_text = charset_to_utf8($mod_text, 'ISO-8859-7'); break; case 'latin5': $mod_text = charset_to_utf8($mod_text, 'ISO-8859-9'); break; case 'latin7': $mod_text = charset_to_utf8($mod_text, 'ISO-8859-13'); break; case 'utf8': default: $mod_text = charset_to_utf8($mod_text, 'UTF-8'); } } else { $mod_text = entities_to_umlauts($mod_text, 'UTF-8'); } $anchor_text = $mod_text; // make an copy containing html-tags $mod_text = strip_tags($mod_text); $mod_text = str_replace(array('>', '<', '&', '"', ''', ''', ' '), array('>', '<', '&', '"', '\'', '\'', ' '), $mod_text); $mod_text = '.' . trim($mod_text) . '.'; // Do a fast scan over $mod_text first. This may speedup things a lot. if ($func_search_match == 'all') { if (!is_all_matched($mod_text, $func_search_words)) { return false; } } elseif (!is_any_matched($mod_text, $func_search_words)) { return false; } // search for an better anchor - this have to be done before strip_tags() (may fail if search-string contains <, &, amp, gt, lt, ...) $anchor = make_url_target($mod_page_link_target, $anchor_text, $func_search_words); // make the link from $mod_page_link, add anchor $link = ""; $link = page_link($mod_page_link); if (strpos($mod_page_link, 'http:') === FALSE) { $link .= make_url_searchstring($func_search_match, $func_search_url_array); } $link .= $anchor; // now get the excerpt $excerpt = ""; $excerpt_array = array(); if ($mod_max_excerpt_num > 0) { if (!($excerpt_array = get_excerpts($mod_text, $func_search_words, $mod_max_excerpt_num))) { return false; } $excerpt = prepare_excerpts($excerpt_array, $func_search_words, $mod_max_excerpt_num); } // handle thumbs - to deactivate this look in the module's search.php: $show_thumb (or maybe in the module's settings-page) if ($mod_pic_link != "") { if (isset($mod_special) && $mod_special == 'lightbox2_plus') { $excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top">' . $mod_special_piclink . '<img src="' . WB_URL . '/' . MEDIA_DIRECTORY . $mod_pic_link . '" alt="" /></a></td><td>' . $excerpt . '</td></tr></tbody></table>'; } else { $excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top"><a href="' . $link . '"><img src="' . WB_URL . '/' . MEDIA_DIRECTORY . $mod_pic_link . '" alt="" /></a></td><td>' . $excerpt . '</td></tr></tbody></table>'; } } // print-out the excerpt $vars = array(); $values = array(); list($date, $time) = get_page_modified($mod_page_modified_when); list($username, $displayname) = get_page_modified_by($mod_page_modified_by, $func_users); $vars = array('[LINK]', '[TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[DESCRIPTION]', '[USERNAME]', '[DISPLAY_NAME]', '[DATE]', '[TIME]', '[TEXT_LAST_UPDATED_BY]', '[TEXT_ON]', '[EXCERPT]'); $values = array($link, $mod_page_title, $func_page_title, $func_page_menu_title, $mod_page_description, $username, $displayname, $date, $time, $TEXT['LAST_UPDATED_BY'], $TEXT['ON'], $excerpt); echo str_replace($vars, $values, $func_results_loop_string); if ($func_enable_flush) { // ATTN: this will bypass output-filters and may break template-layout or -filters ob_flush(); flush(); } return true; }
/** * This is the main function for all module search functions. * * @param array $search_result - variables given from the module or droplep * @param array $search_parameter - variables given from the LEPTON search to the module * @return boolean true if the search result of the module match or false in all other cases */ function print_excerpt2($search_result, $search_parameter) { // check the search result variables if ($search_result['text'] == "") { return false; } if (!isset($search_result['page_link'])) { $search_result['page_link'] = $search_parameter['page_link']; } if (!isset($search_result['page_link_target'])) { $search_result['page_link_target'] = ""; } if (!isset($search_result['page_title'])) { $search_result['page_title'] = $search_parameter['page_title']; } if (!isset($search_result['page_description'])) { $search_result['page_description'] = $search_parameter['page_description']; } if (!isset($search_result['page_modified_when'])) { $search_result['page_modified_when'] = $search_parameter['page_modified_when']; } if (!isset($search_result['page_modified_by'])) { $search_result['page_modified_by'] = $search_parameter['page_modified_by']; } if (!isset($search_result['text'])) { $search_result['text'] = ""; } if (!isset($search_result['max_excerpt_num'])) { $search_result['max_excerpt_num'] = $search_parameter['default_max_excerpt']; } // special: image links if (!isset($search_result['pic_link'])) { $search_result['pic_link'] = ''; } if (!isset($search_result['image_link'])) { $search_result['image_link'] = $search_result['pic_link']; } if (!isset($search_result['no_highlight'])) { $search_result['no_highlight'] = false; } if (isset($search_result['ext_charset'])) { $search_result['ext_charset'] = strtolower($search_result['ext_charset']); } else { $search_result['ext_charset'] = ''; } if ($search_result['no_highlight']) { // suppress highlighting of search results $search_result['page_link_target'] = "&nohighlight=1" . $search_result['page_link_target']; } // clean the text: $search_result['text'] = preg_replace('#<(br|dt|/dd|/?(?:h[1-6]|tr|table|p|li|ul|pre|code|div|hr))[^>]*>#i', '.', $search_result['text']); $search_result['text'] = preg_replace('#<(!--.*--|style.*</style|script.*</script)>#iU', ' ', $search_result['text']); $search_result['text'] = preg_replace('#\\[\\[.*?\\]\\]#', '', $search_result['text']); //Filter droplets from the page data // strip_tags() is called below if ($search_result['ext_charset'] != '') { // data from external database may have a different charset require_once CAT_PATH . '/framework/functions-utf8.php'; switch ($search_result['ext_charset']) { case 'latin1': case 'cp1252': $search_result['text'] = charset_to_utf8($search_result['text'], 'CP1252'); break; case 'cp1251': $search_result['text'] = charset_to_utf8($search_result['text'], 'CP1251'); break; case 'latin2': $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-2'); break; case 'hebrew': $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-8'); break; case 'greek': $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-7'); break; case 'latin5': $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-9'); break; case 'latin7': $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-13'); break; case 'utf8': default: $search_result['text'] = charset_to_utf8($search_result['text'], 'UTF-8'); } } else { $search_result['text'] = entities_to_umlauts($search_result['text'], 'UTF-8'); } $content_locked = ''; $add_anchor = true; if (isset($_SESSION[SESSION_SEARCH_NON_PUBLIC_CONTENT])) { // show non-public contents, so add some extra informations if (isset($_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT]) && !empty($_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT])) { // link to a special page, defined in search as CFG_LINK_NON_PUBLIC_CONTENT $search_result['page_link'] = CAT_URL . $_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT]; } else { $search_result['page_link'] = ''; } // $_SESSION reset unset($_SESSION[SESSION_SEARCH_NON_PUBLIC_CONTENT]); unset($_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT]); $add_anchor = false; } $anchor_text = $search_result['text']; // make an copy containing html-tags $search_result['text'] = strip_tags($search_result['text']); $search_result['text'] = str_replace(array('>', '<', '&', '"', ''', ''', ' '), array('>', '<', '&', '"', '\'', '\'', ' '), $search_result['text']); $search_result['text'] = '.' . trim($search_result['text']) . '.'; // create empty image array $images = array(); if ($search_parameter['settings'][CFG_SEARCH_IMAGES] || $search_parameter['settings'][CFG_CONTENT_IMAGE]) { // we need a image array for the search preg_match_all('/<img[^>]*>/', $anchor_text, $matches); foreach ($matches as $match) { foreach ($match as $img_tag) { // <img ...> zerlegen preg_match_all('/([a-zA-Z]*[a-zA-Z])\\s{0,3}[=]\\s{0,3}("[^"\\r\\n]*)"/', $img_tag, $attr); foreach ($attr as $attributes) { $img = array(); foreach ($attributes as $attribut) { if (strpos($attribut, "=") !== false) { list($key, $value) = explode("=", $attribut); $value = trim($value); $value = substr($value, 1, strlen($value) - 2); $img[strtolower(trim($key))] = trim($value); } } if (isset($img['src'])) { $images[] = $img; } } } } } if (!$search_parameter['settings'][CFG_SEARCH_IMAGES] && $search_parameter['settings'][CFG_CONTENT_IMAGE] == CONTENT_IMAGE_NONE) { // Do a fast scan over the search result first. This may speedup things a lot. if ($search_parameter['search_match'] == SEARCH_TYPE_ALL) { if (!is_all_matched($search_result['text'], $search_parameter['search_words'])) { return false; } } elseif (!is_any_matched($search_result['text'], $search_parameter['search_words'])) { return false; } } else { // create a dummy string to check matches in the images $divider = '.'; $image_text = ''; foreach ($images as $image) { $file = basename($image['src']); $file = urldecode(substr($file, 0, strrpos($file, '.'))); $alt = isset($image['alt']) && !empty($image['alt']) ? $image['alt'] : ''; $title = isset($image['title']) && !empty($image['title']) ? $image['title'] : ''; $image_text .= $alt == $title ? $divider . $alt . $divider . $file . $divider : $divider . $alt . $divider . $title . $divider . $file . $divider; } if ($search_parameter['search_match'] == SEARCH_TYPE_ALL) { if (!is_all_matched($search_result['text'] . $image_text, $search_parameter['search_words'])) { return false; } } elseif (!is_any_matched($search_result['text'] . $image_text, $search_parameter['search_words'])) { return false; } } // search for an better anchor - this have to be done before strip_tags() (may fail if search-string contains <, &, amp, gt, lt, ...) $anchor = make_url_target($search_result['page_link_target'], $anchor_text, $search_parameter['search_words']); // make the link from $mod_page_link, add anchor $link = ""; if (!empty($search_result['page_link'])) { $link = page_link($search_result['page_link']); if (strpos($search_result['page_link'], 'http:') === false) { $link .= make_url_searchstring($search_parameter['search_match'], $search_parameter['search_url_array']); } // add anchor only if content is not locked! if ($add_anchor) { $link .= $anchor; } } // now get the excerpt $excerpt = ""; $excerpt_array = array(); // dont create excerpts if we are only searching for images! if ($search_parameter['search_match'] != SEARCH_TYPE_IMAGE && $search_result['max_excerpt_num'] > 0) { if (false !== ($excerpt_array = get_excerpts($search_result['text'], $search_parameter['search_words'], $search_result['max_excerpt_num']))) { $excerpt = prepare_excerpts($excerpt_array, $search_parameter['search_words'], $search_result['max_excerpt_num']); } } // no image matches now ... $image_match = false; $image_array = array(); if ($search_parameter['settings'][CFG_SEARCH_IMAGES] || $search_parameter['search_match'] == SEARCH_TYPE_ALL) { // ok - now we are looking for matching images ... foreach ($images as $image) { $file = urldecode(basename($image['src'])); $file = substr($file, 0, strrpos($file, '.')); $alt = isset($image['alt']) && !empty($image['alt']) ? $image['alt'] : ''; $title = isset($image['title']) && !empty($image['title']) ? $image['title'] : ''; $image_text = $alt == $title ? $divider . $alt . $divider . $file . $divider : $divider . $alt . $divider . $title . $divider . $file . $divider; if (false !== ($excerpt_array = get_excerpts($image_text, $search_parameter['search_words'], $search_result['max_excerpt_num']))) { // image match! $image_excerpt = prepare_excerpts($excerpt_array, $search_parameter['search_words'], $search_result['max_excerpt_num']); // accept only images with complete URL if (false === strpos($image['src'], CAT_URL)) { continue; } $src = str_ireplace(CAT_URL, CAT_PATH, urldecode($image['src'])); $target = CAT_PATH . '/temp/search/' . urldecode(basename($image['src'])); makeThumbnail($src, $target, $search_parameter['settings'][CFG_THUMBS_WIDTH]); $image_array[] = array('excerpt' => $image_excerpt, 'src' => CAT_URL . '/temp/search/' . urldecode(basename($image['src'])), 'alt' => isset($image['alt']) ? $image['alt'] : '', 'title' => isset($image['title']) ? $image['title'] : '', 'width' => $search_parameter['settings'][CFG_THUMBS_WIDTH]); $image_match = true; } } } // leave here if nothing matches ... if (empty($excerpt) && !$image_match) { return false; } $thumb_array = array(); // if no images are matching to the search it's possible to show a image // of the content or to use a desired image_link from the module $use_thumb = 0; if (!$image_match && ($search_parameter['settings'][CFG_CONTENT_IMAGE] != CONTENT_IMAGE_NONE || !empty($search_result['image_link']))) { if (!empty($search_result['image_link'])) { if (strpos($search_result['image_link'], CAT_URL) === false) { $src = CAT_PATH . MEDIA_DIRECTORY . DIRECTORY_SEPARATOR . $search_result['image_link']; } else { $src = str_ireplace(CAT_URL, CAT_PATH, $search_result['image_link']); } // the path to the temporary thumbnail $target = CAT_PATH . '/temp/search/' . basename($search_result['image_link']); // create a thumbnail and place it in the temporary directory if (makeThumbnail($src, $target, $search_parameter['settings'][CFG_THUMBS_WIDTH])) { $thumb_array = array('src' => CAT_URL . '/temp/search/' . urldecode(basename($search_result['image_link'])), 'alt' => $search_result['page_title'], 'title' => $search_result['page_title'], 'width' => $search_parameter['settings'][CFG_THUMBS_WIDTH]); $use_thumb = 1; } else { $use_thumb = 0; } } else { switch ($search_parameter['settings'][CFG_CONTENT_IMAGE]) { case CONTENT_IMAGE_FIRST: $i = 0; break; case CONTENT_IMAGE_LAST: $i = count($images) - 1; break; case CONTENT_IMAGE_RANDOM: $i = rand(0, count($images) - 1); break; default: $i = 0; } if (isset($images[$i]['src']) && false !== strpos($images[$i]['src'], CAT_URL)) { $src = str_ireplace(CAT_URL, CAT_PATH, urldecode($images[$i]['src'])); // the path to the temporary thumbnail $target = CAT_PATH . '/temp/search/' . urldecode(basename($images[$i]['src'])); // create a thumbnail and place it in the temporary directory if (makeThumbnail($src, $target, $search_parameter['settings'][CFG_THUMBS_WIDTH])) { $thumb_array = array('src' => CAT_URL . '/temp/search/' . urldecode(basename($images[$i]['src'])), 'alt' => isset($images[$i]['alt']) ? $images[$i]['alt'] : '', 'title' => isset($images[$i]['title']) ? $images[$i]['title'] : '', 'width' => $search_parameter['settings'][CFG_THUMBS_WIDTH]); $use_thumb = 1; } else { $use_thumb = 0; } } else { $use_thumb = 0; } } } else { $use_thumb = 0; } list($date, $time) = get_page_modified($search_result['page_modified_when']); list($username, $displayname) = get_page_modified_by($search_result['page_modified_by'], $search_parameter['users']); $item = array('page' => array('link' => $link, 'title' => $search_result['page_title'], 'description' => $search_result['page_description'], 'excerpt' => $excerpt, 'images' => array('items' => $image_array, 'count' => count($image_array)), 'thumb' => array('active' => $use_thumb, 'image' => $thumb_array), 'last_changed' => array('unix_time' => $search_result['page_modified_when'], 'date_formatted' => $date, 'time_formatted' => $time), 'visibility' => $search_parameter['page_visibility']), 'user' => array('name' => $username, 'display_name' => $displayname)); // all search results are temporary saved in the $_SESSION['SEARCH_RESULT_ITEMS'] if (!isset($_SESSION[SESSION_SEARCH_RESULT_ITEMS])) { $_SESSION[SESSION_SEARCH_RESULT_ITEMS] = array(); } $_SESSION[SESSION_SEARCH_RESULT_ITEMS][] = $item; return true; }
/** * Prepare the search before really executing * * @access protected */ protected function prepareSearch() { global $wb; $search_entities_string = ''; // for SQL's LIKE $search_display_string = ''; // for displaying $search_url_string = ''; // for $_GET -- ATTN: unquoted! Will become urldecoded later $string = ''; if (isset($_REQUEST[REQUEST_SEARCH_STRING])) { if ($this->search_type != SEARCH_TYPE_EXACT) { // remove all comma's $string = str_replace(',', '', $_REQUEST[REQUEST_SEARCH_STRING]); } else { $string = $_REQUEST[REQUEST_SEARCH_STRING]; } // redo possible magic quotes $string = stripslashes($string); $string = preg_replace('/[ \\r\\n\\t]+/', ' ', $string); $string = trim($string); // remove some bad chars $string = str_replace(array('[[', ']]'), '', $string); $string = preg_replace('/(^|\\s+)[|.]+(?=\\s+|$)/', '', $string); $search_display_string = htmlspecialchars($string); $search_entities_string = addslashes(umlauts_to_entities(htmlspecialchars($string))); // mySQL needs four backslashes to match one in LIKE comparisons) $search_entities_string = str_replace('\\\\', '\\\\\\\\', $search_entities_string); // convert string to utf-8 $string = entities_to_umlauts($string, 'UTF-8'); $search_url_string = $string; $search_entities_string = addslashes(htmlentities($string, ENT_COMPAT, 'UTF-8')); // mySQL needs four backslashes to match one in LIKE comparisons) $search_entities_string = str_replace('\\\\', '\\\\\\\\', $search_entities_string); $string = preg_quote($string); // quote ' " and / -we need quoted / for regex $this->search_string = str_replace(array('\'', '"', '/'), array('\\\'', '\\"', '\\/'), $string); } // make arrays from the search_..._strings above if ($this->search_type == SEARCH_TYPE_EXACT) { $this->search_url_array[] = $search_url_string; } else { $this->search_url_array = explode(' ', $search_url_string); } $search_normal_array = array(); $this->search_entities_array = array(); if ($this->search_type == SEARCH_TYPE_EXACT) { $search_normal_array[] = $this->search_string; $this->search_entities_array[] = $search_entities_string; } else { $exploded_string = explode(' ', $this->search_string); // Make sure there is no blank values in the array foreach ($exploded_string as $each_exploded_string) { if ($each_exploded_string != '') { $search_normal_array[] = $each_exploded_string; } } $exploded_string = explode(' ', $search_entities_string); // Make sure there is no blank values in the array foreach ($exploded_string as $each_exploded_string) { if ($each_exploded_string != '') { $this->search_entities_array[] = $each_exploded_string; } } } // make an extra copy of search_normal_array for use in regex $this->search_words = array(); // include the translation tables for special chars $search_language = $this->search_language; include_once LEPTON_PATH . '/modules/' . basename(dirname(__FILE__)) . '/search.convert.php'; global $search_table_umlauts_local; include_once LEPTON_PATH . '/modules/' . basename(dirname(__FILE__)) . '/search.convert.umlaute.php'; global $search_table_ul_umlauts; foreach ($search_normal_array as $str) { $str = strtr($str, $search_table_umlauts_local); $str = strtr($str, $search_table_ul_umlauts); $this->search_words[] = $str; } }