OR ', $or_arr[$j]); $j++; } } // build a NOT array from the items in AND foreach($and_arr as $key => $val) { if (substr($val,0,1) == '-') { $not_arr[] = substr($val,1); unset($and_arr[$key]); } elseif(substr($val,0,1) == '+') { $and_arr[] = substr($val,1); unset($and_arr[$key]); } } // prepare our formatted search string if (count($and_arr) > 1) { $final_str_arr[] = implode(' AND ', $and_arr); } elseif (isset($and_arr[0]) && $and_arr[0] != '') { $final_str_arr[] = $and_arr[0]; } if (count($or_str_arr) > 1) { $final_str_arr[] = implode(' AND ', $or_str_arr); } elseif (isset($or_str_arr[0]) && $or_str_arr[0] != '') { $final_str_arr[] = $or_str_arr[0]; } if (count($not_arr) > 1) { $final_str_arr[] = '-'.implode(' AND -', $not_arr); } elseif (isset($not_arr[0]) && $not_arr[0] != '') { $final_str_arr[] = '-'.$not_arr[0]; } if (count($final_str_arr) > 1) { $formatted_search = ''.implode(' AND ', $final_str_arr).''; } else { $formatted_search = ''.$final_str_arr[0].''; } return array($formatted_search, $and_arr, $or_arr, $not_arr); } // takes an array made by format_search() and checks to see if it // it matches against a string function search_boolean($needle_arr, $haystack) { // init arrays $and_arr = $needle_arr[1]; $or_arr = $needle_arr[2]; $not_arr = $needle_arr[3]; // compare lowercase versions of the strings $haystack = strtolower($haystack); // check against the NOT foreach($not_arr as $s) { if (ereg($s, $haystack) == true) { return false; } } // check against the AND foreach($and_arr as $s) { if (ereg($s,$haystack) == false) { return false; } } // check against the OR foreach($or_arr as $or) { $is_false = true; foreach($or as $s) { if (substr($s,0,1) == '-') { if (ereg(substr($s,1),$haystack) == false) { $is_false = false; break; } } elseif (ereg($s,$haystack) == true) { $is_false = false; break; } } if ($is_false) return false; } // if we haven't returned false, then we return true return true; } $search_string = 'final'; $format_search_arr = format_search($search_string); $formatted_search = $format_search_arr[0]; if (isset($master_array) && is_array($master_array)) { foreach($master_array as $date_key_tmp => $date_tmp) { if (is_array($date_tmp)) { foreach($date_tmp as $time_tmp) { if (is_array($time_tmp)) { foreach ($time_tmp as $event_tmp) { if (is_array($event_tmp)) { $results1 = search_boolean($format_search_arr,$event_tmp['event_text']); if (!$results1) { $results2 = search_boolean($format_search_arr,$event_tmp['description']); } if ($results1 || $results2) { $event_tmp['date'] = $date_key_tmp; $the_arr[] = $event_tmp; } } } } } } } } ?> <?php echo "$calendar_name - Search Results"; ?> ">
"; ?> "; ?>
\n"; echo "\n"; echo "\n"; } else { echo "\n"; echo "\n"; echo "\n"; } ?>
"; ?> "; ?>
\n"; foreach($the_arr as $val) { $thedate = $val['date']; $dayofmonth = strtotime ($thedate); $dayofmonth = localizeDate ($dateFormat_week_list, $dayofmonth); $i = 0; if ($getdate == $thedate) { $fontclass="class=\"G10BOLD\""; } else { $fontclass="class=\"G10B\""; } if ($val["event_text"]) { $event_text = stripslashes(urldecode($val["event_text"])); $event_text2 = addslashes($val["event_text"]); $event_text2 = str_replace("\"", """, $event_text2); $event_text2 = urlencode($event_text2); $description = addslashes($val["description"]); $description = str_replace("\"", """, $description); $event_start = $val["event_start"]; $event_end = $val["event_end"]; $event_start = date ($timeFormat, strtotime ("$event_start")); $event_end = date ($timeFormat, strtotime ("$event_end")); $event_text = str_replace ("
", "", $event_text); $event_start2 = $event_start; if (strlen($event_text) > 70) { $event_text = substr("$event_text", 0, 65); $event_text = $event_text . "..."; } if (!$val["event_start"]) { $event_start = "$all_day_lang"; $event_start2 = ''; $event_end = ''; } echo "\n"; echo "\n"; echo "\n"; } } echo "
 $dayofmonth ($event_start)\n"; echo " $event_text\n"; echo "\n"; echo ''.htmlspecialchars(urldecode($val["description"])).''; echo "
No results found