diff --git a/inc/html.php b/inc/html.php index 16269d0a847045c3369d7c1e089e1dd21e51890f..cd8651dde5e33a7ab5d2ae6736f0265e47d94a10 100644 --- a/inc/html.php +++ b/inc/html.php @@ -536,7 +536,7 @@ function html_search(){ //do quick pagesearch $data = array(); - search($data,$conf['datadir'],'search_pagename',array(query => $QUERY)); + search($data,$conf['datadir'],'search_pagename',array(query => cleanID($QUERY))); if(count($data)){ sort($data); print '<div class="search_quickresult">'; @@ -554,7 +554,7 @@ function html_search(){ //do fulltext search $data = array(); - search($data,$conf['datadir'],'search_fulltext',array(query => $QUERY)); + search($data,$conf['datadir'],'search_fulltext',array(query => utf8_strtolower($QUERY))); if(count($data)){ usort($data,'sort_search_fulltext'); foreach($data as $row){ diff --git a/inc/search.php b/inc/search.php index ebc7eda9dcbd15974dbbaded6f18e33978a7b20a..725cd22c95ef2efb8d5f33b970ed5dda24164311 100644 --- a/inc/search.php +++ b/inc/search.php @@ -269,6 +269,8 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){ //get text $text = io_readfile($base.'/'.$file); + //lowercase text (u modifier does not help with case) + $lctext = utf8_strtolower($text); //create regexp from queries $qpreg = preg_split('/\s+/',preg_quote($opts['query'],'#')); @@ -276,17 +278,17 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){ //do the fulltext search $matches = array(); - if($cnt = preg_match_all('#'.$qpreg.'#si',$text,$matches)){ + if($cnt = preg_match_all('#'.$qpreg.'#usi',$lctext,$matches)){ //this is not the best way for snippet generation but the fastest I could find //split query and only use the first token $q = preg_split('/\s+/',$opts['query'],2); $q = $q[0]; - $p = strpos(strtolower($text),$q); + $p = utf8_strpos($lctext,$q); $f = $p - 100; - $l = strlen($q) + 200; + $l = utf8_strlen($q) + 200; if($f < 0) $f = 0; $snippet = '<span class="search_sep"> ... </span>'. - htmlspecialchars(substr($text,$f,$l)). + htmlspecialchars(utf8_substr($text,$f,$l)). '<span class="search_sep"> ... </span>'; $snippet = preg_replace('#'.$qpreg.'#si','<span class="search_hit">\\1</span>',$snippet);