Revision 1094
Added by Matthias over 15 years ago
search.php | ||
---|---|---|
117 | 117 |
} |
118 | 118 |
} |
119 | 119 |
|
120 |
// Get search language |
|
120 |
// Get search language, used for special umlaut handling (DE: ß=ss, ...)
|
|
121 | 121 |
$search_lang = ''; |
122 | 122 |
if(isset($_REQUEST['search_lang'])) { |
123 | 123 |
$search_lang = $_REQUEST['search_lang']; |
... | ... | |
143 | 143 |
$search_path_SQL = ''; |
144 | 144 |
$search_path = ''; |
145 | 145 |
if(isset($_REQUEST['search_path'])) { |
146 |
$search_path = addslashes(htmlspecialchars(strip_tags($wb->strip_slashes($_REQUEST['search_path'])))); |
|
146 |
$search_path = addslashes(htmlspecialchars(strip_tags($wb->strip_slashes($_REQUEST['search_path'])), ENT_QUOTES));
|
|
147 | 147 |
if(!preg_match('~^%?[-a-zA-Z0-9_,/ ]+$~', $search_path)) |
148 | 148 |
$search_path = ''; |
149 | 149 |
if($search_path != '') { |
... | ... | |
168 | 168 |
} |
169 | 169 |
} |
170 | 170 |
|
171 |
// use page_languages? |
|
172 |
if(PAGE_LANGUAGES) { |
|
173 |
$table = TABLE_PREFIX."pages"; |
|
174 |
$search_language_SQL_t = "AND $table.`language` = '".LANGUAGE."'"; |
|
175 |
$search_language_SQL = "AND `language` = '".LANGUAGE."'"; |
|
176 |
} else { |
|
177 |
$search_language_SQL_t = ''; |
|
178 |
$search_language_SQL = ''; |
|
179 |
} |
|
180 |
|
|
171 | 181 |
// Get the search type |
172 | 182 |
$match = ''; |
173 | 183 |
if(isset($_REQUEST['match'])) { |
... | ... | |
236 | 246 |
} |
237 | 247 |
} |
238 | 248 |
// make an extra copy of search_normal_array for use in regex |
239 |
require_once(WB_PATH.'/search/search_convert.php');
|
|
249 |
require(WB_PATH.'/search/search_convert.php'); |
|
240 | 250 |
$search_words = array(); |
241 | 251 |
foreach($search_normal_array AS $str) { |
242 | 252 |
$str = str_replace($string_ul_umlaut, $string_ul_regex, $str); |
... | ... | |
344 | 354 |
// now call module-based $search_funcs[] |
345 | 355 |
$seen_pages = array(); // seen pages per module. |
346 | 356 |
$pages_listed = array(); // seen pages. |
347 |
foreach($sorted_modules AS $module_name) { |
|
348 |
$start_time = time(); // get start-time to check time-limit; not very accurate, but ok |
|
349 |
$seen_pages[$module_name] = array(); |
|
350 |
if(!isset($search_funcs[$module_name])) { |
|
351 |
continue; // there is no search_func for this module |
|
352 |
} |
|
353 |
// get each section for $module_name |
|
354 |
$table_s = TABLE_PREFIX."sections"; |
|
355 |
$table_p = TABLE_PREFIX."pages"; |
|
356 |
$sections_query = $database->query(" |
|
357 |
SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end, |
|
358 |
p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by, |
|
359 |
p.visibility, p.viewing_groups, p.viewing_users |
|
360 |
FROM $table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id |
|
361 |
WHERE s.module = '$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL |
|
362 |
ORDER BY s.page_id, s.position ASC |
|
363 |
"); |
|
364 |
if($sections_query->numRows() > 0) { |
|
365 |
while($res = $sections_query->fetchRow()) { |
|
366 |
// check if time-limit is exceeded for this module |
|
367 |
if($search_time_limit > 0 && (time()-$start_time > $search_time_limit)) { |
|
368 |
break; |
|
369 |
} |
|
370 |
// Only show this section if it is not "out of publication-date" |
|
371 |
$now = time(); |
|
372 |
if( !( $now<$res['publ_end'] && ($now>$res['publ_start'] || $res['publ_start']==0) || |
|
373 |
$now>$res['publ_start'] && $res['publ_end']==0) ) { |
|
374 |
continue; |
|
375 |
} |
|
376 |
$search_func_vars = array( |
|
377 |
'database' => $database, |
|
378 |
'page_id' => $res['page_id'], |
|
379 |
'section_id' => $res['section_id'], |
|
380 |
'page_title' => $res['page_title'], |
|
381 |
'page_menu_title' => $res['menu_title'], |
|
382 |
'page_description' => ($cfg_show_description?$res['description']:""), |
|
383 |
'page_keywords' => $res['keywords'], |
|
384 |
'page_link' => $res['link'], |
|
385 |
'page_modified_when' => $res['modified_when'], |
|
386 |
'page_modified_by' => $res['modified_by'], |
|
387 |
'users' => $users, |
|
388 |
'search_words' => $search_words, // needed for preg_match |
|
389 |
'search_match' => $match, |
|
390 |
'search_url_array' => $search_url_array, // needed for url-string only |
|
391 |
'results_loop_string' => $fetch_results_loop['value'], |
|
392 |
'default_max_excerpt' => $search_max_excerpt, |
|
393 |
'enable_flush' => $cfg_enable_flush |
|
394 |
); |
|
395 |
// Only show this page if we are allowed to see it |
|
396 |
if($admin->page_is_visible($res) == false) { |
|
397 |
if($res['visibility'] == 'registered') { // don't show excerpt |
|
398 |
$search_func_vars['default_max_excerpt'] = 0; |
|
399 |
$search_func_vars['page_description'] = $TEXT['REGISTERED']; |
|
400 |
} else { // private |
|
357 |
if($search_max_excerpt!=0) { // skip this search if $search_max_excerpt==0 |
|
358 |
foreach($sorted_modules AS $module_name) { |
|
359 |
$start_time = time(); // get start-time to check time-limit; not very accurate, but ok |
|
360 |
$seen_pages[$module_name] = array(); |
|
361 |
if(!isset($search_funcs[$module_name])) { |
|
362 |
continue; // there is no search_func for this module |
|
363 |
} |
|
364 |
// get each section for $module_name |
|
365 |
$table_s = TABLE_PREFIX."sections"; |
|
366 |
$table_p = TABLE_PREFIX."pages"; |
|
367 |
$sections_query = $database->query(" |
|
368 |
SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end, |
|
369 |
p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by, |
|
370 |
p.visibility, p.viewing_groups, p.viewing_users |
|
371 |
FROM $table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id |
|
372 |
WHERE s.module = '$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL $search_language_SQL |
|
373 |
ORDER BY s.page_id, s.position ASC |
|
374 |
"); |
|
375 |
if($sections_query->numRows() > 0) { |
|
376 |
while($res = $sections_query->fetchRow()) { |
|
377 |
// check if time-limit is exceeded for this module |
|
378 |
if($search_time_limit > 0 && (time()-$start_time > $search_time_limit)) { |
|
379 |
break; |
|
380 |
} |
|
381 |
// Only show this section if it is not "out of publication-date" |
|
382 |
$now = time(); |
|
383 |
if( !( $now<$res['publ_end'] && ($now>$res['publ_start'] || $res['publ_start']==0) || |
|
384 |
$now>$res['publ_start'] && $res['publ_end']==0) ) { |
|
401 | 385 |
continue; |
402 | 386 |
} |
387 |
$search_func_vars = array( |
|
388 |
'database' => $database, |
|
389 |
'page_id' => $res['page_id'], |
|
390 |
'section_id' => $res['section_id'], |
|
391 |
'page_title' => $res['page_title'], |
|
392 |
'page_menu_title' => $res['menu_title'], |
|
393 |
'page_description' => ($cfg_show_description?$res['description']:""), |
|
394 |
'page_keywords' => $res['keywords'], |
|
395 |
'page_link' => $res['link'], |
|
396 |
'page_modified_when' => $res['modified_when'], |
|
397 |
'page_modified_by' => $res['modified_by'], |
|
398 |
'users' => $users, |
|
399 |
'search_words' => $search_words, // needed for preg_match |
|
400 |
'search_match' => $match, |
|
401 |
'search_url_array' => $search_url_array, // needed for url-string only |
|
402 |
'results_loop_string' => $fetch_results_loop['value'], |
|
403 |
'default_max_excerpt' => $search_max_excerpt, |
|
404 |
'enable_flush' => $cfg_enable_flush, |
|
405 |
'time_limit' => $search_time_limit // time-limit in secs |
|
406 |
); |
|
407 |
// Only show this page if we are allowed to see it |
|
408 |
if($admin->page_is_visible($res) == false) { |
|
409 |
if($res['visibility'] == 'registered') { // don't show excerpt |
|
410 |
$search_func_vars['default_max_excerpt'] = 0; |
|
411 |
$search_func_vars['page_description'] = $TEXT['REGISTERED']; |
|
412 |
} else { // private |
|
413 |
continue; |
|
414 |
} |
|
415 |
} |
|
416 |
$uf_res = call_user_func($search_funcs[$module_name], $search_func_vars); |
|
417 |
if($uf_res) { |
|
418 |
$pages_listed[$res['page_id']] = true; |
|
419 |
$seen_pages[$module_name][$res['page_id']] = true; |
|
420 |
} else { |
|
421 |
$seen_pages[$module_name][$res['page_id']] = true; |
|
422 |
} |
|
403 | 423 |
} |
404 |
$uf_res = call_user_func($search_funcs[$module_name], $search_func_vars); |
|
405 |
if($uf_res) { |
|
406 |
$pages_listed[$res['page_id']] = true; |
|
407 |
$seen_pages[$module_name][$res['page_id']] = true; |
|
408 |
} else { |
|
409 |
$seen_pages[$module_name][$res['page_id']] = true; |
|
410 |
} |
|
411 | 424 |
} |
412 | 425 |
} |
413 | 426 |
} |
... | ... | |
445 | 458 |
SELECT page_id, page_title, menu_title, link, description, keywords, modified_when, modified_by, |
446 | 459 |
visibility, viewing_groups, viewing_users |
447 | 460 |
FROM $table |
448 |
WHERE visibility NOT IN ('none','deleted') AND searching = '1' $search_path_SQL |
|
461 |
WHERE visibility NOT IN ('none','deleted') AND searching = '1' $search_path_SQL $search_language_SQL
|
|
449 | 462 |
"); |
450 | 463 |
if($query_pages->numRows() > 0) { |
451 | 464 |
while($page = $query_pages->fetchRow()) { |
... | ... | |
602 | 615 |
} |
603 | 616 |
$prepared_query .= " ) ) ) ".$query_end; |
604 | 617 |
// Execute query |
605 |
$page_query = $database->query($prepared_query." ".$search_path_SQL); |
|
618 |
$page_query = $database->query($prepared_query." ".$search_path_SQL." ".$search_language_SQL_t);
|
|
606 | 619 |
|
607 | 620 |
// Loop through queried items |
608 | 621 |
if($page_query->numRows() > 0) { |
Also available in: Unified diff
fixed some language bugs in search.php (Thanks to Thorn)