428 | | $q['s'] = addslashes_gpc($q['s']); |
429 | | $search = ' AND ('; |
430 | | $q['s'] = preg_replace('/, +/', ' ', $q['s']); |
431 | | $q['s'] = str_replace(',', ' ', $q['s']); |
432 | | $q['s'] = str_replace('"', ' ', $q['s']); |
433 | | $q['s'] = trim($q['s']); |
434 | | if ($q['exact']) { |
435 | | $n = ''; |
436 | | } else { |
437 | | $n = '%'; |
| 428 | // added slashes screw with quote grouping when done early, so done later |
| 429 | $q['s'] = stripslashes($q['s']); |
| 430 | if ($q['sentence']) { |
| 431 | $q['search_terms'] = array($q['s']); |
439 | | if (!$q['sentence']) { |
440 | | $s_array = explode(' ',$q['s']); |
441 | | $q['search_terms'] = $s_array; |
442 | | $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))'; |
443 | | for ( $i = 1; $i < count($s_array); $i = $i + 1) { |
444 | | $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))'; |
445 | | } |
446 | | $search .= ' OR (post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\')'; |
447 | | $search .= ')'; |
448 | | } else { |
449 | | $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))'; |
| 433 | else { |
| 434 | preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q[s], $matches); |
| 435 | $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); |