'."\n". ''."\n". ''."\n". ''."\n". ''."\n". ''; $search_started = getmicrotime(); if ($search_valid) { $format_search_arr = format_search($query); $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 $uid_tmp => $event_tmp) { if (is_array($event_tmp)) { if (!isset($the_arr[$uid_tmp]) || isset($event_tmp['exception'])) { $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; if (isset($event_tmp['recur'])) { $event_tmp['recur'] = format_recur($event_tmp['recur']); } if (isset($the_arr[$uid_tmp])) { $the_arr[$uid_tmp]['exceptions'][] = $event_tmp; } else { $the_arr[$uid_tmp] = $event_tmp; } } } } } } } } } } } else { $formatted_search = 'No query given'; } $search_ended = getmicrotime(); $search_took = number_format(($search_ended-$search_started),3); ?> <?php echo "$calendar_name - $results_lang"; ?>
\n"; echo ""; echo "\n"; if ($val["event_text"]) { $event_text = stripslashes(urldecode($val["event_text"])); $description = stripslashes(urldecode($val["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_start = "$event_start - $event_end"; if (!$val["event_start"]) { $event_start = "$all_day_lang"; $event_start2 = ''; $event_end = ''; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (isset($val['exceptions'])) { foreach($val['exceptions'] as $val2) { $key = $val2['date']; $dayofmonth = strtotime ($key); $dayofmonth = localizeDate ($dateFormat_day, $dayofmonth); echo "\n"; echo ""; echo "\n"; if ($val2["event_text"]) { $event_text = stripslashes(urldecode($val2["event_text"])); $description = stripslashes(urldecode($val2["description"])); $event_start = $val2["event_start"]; $event_end = $val2["event_end"]; $event_start = date ($timeFormat, strtotime ("$event_start")); $event_end = date ($timeFormat, strtotime ("$event_end")); $event_start = "$event_start - $event_end"; if (!$val2["event_start"]) { $event_start = "$all_day_lang"; $event_start2 = ''; $event_end = ''; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } } } } } } else { echo ''; } ?>
 
$dayofmonth
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (isset($val['recur'])) { $recur = $val['recur']; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if ($val["description"]) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
$time_lang:$event_start
$summary_lang:$event_text
Recurring event:$recur
$description_lang:$description
\n"; echo "
Exception: $dayofmonth
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (isset($val2['recur'])) { $recur = $val2['recur']; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if ($val2["description"]) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
$time_lang:$event_start
$summary_lang:$event_text
Recurring event:$recur
$description_lang:$description
\n"; echo "
'; echo $no_results_lang; echo '
 
Search took '.$search_took.' seconds

'; ?>
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; } function format_recur($arr) { global $monthsofyearshort_lang, $daysofweekshort_lang; $freq = $arr['FREQ'].(($arr['INTERVAL'] == 1) ? ' ' : 's '); $int = $arr['INTERVAL']; if (isset($arr['COUNT'])) $times = $arr['COUNT'].' time'.(($arr['COUNT'] == 1) ? ' ' : 's '); if (isset($arr['UNTIL'])) $until = 'until '.$arr['UNTIL'].' '; $by = ''; if (isset($arr['BYMONTH'])) { $by .= 'on '; $count = count($arr['BYMONTH']); $last = $count - 1; if ($count == 1) { $month = $arr['BYMONTH'][0]; $by .= $monthsofyearshort_lang[($month-1)]; } else { foreach ($arr['BYMONTH'] as $key => $month) { if ($key == $last) $by .= $monthsofyearshort_lang[($month-1)]; else $by .= $monthsofyearshort_lang[($month-1)].', '; } } $by .= ' '; } if (isset($arr['BYMONTHDAY'])) { $by .= 'on '; $last = count($arr['BYMONTHDAY']) - 1; if ($arr['BYMONTHDAY'][$last] == '0') unset($arr['BYMONTHDAY'][$last]); $count = count($arr['BYMONTHDAY']); $last = $count - 1; if ($count == 1) { ereg('([\-]{0,1})([0-9]{1,2})',$arr['BYMONTHDAY'][0],$regs); list($junk,$sign,$day) = $regs; $by .= $day; } else { foreach ($arr['BYMONTHDAY'] as $key => $day) { ereg('([\-]{0,1})([0-9]{1,2})',$day,$regs); list($junk,$sign,$day) = $regs; if ($key == $last) $by .= $day; else $by .= $day.', '; } } $by .= ' '; } if (isset($arr['BYDAY'])) { $by .= 'on '; $count = count($arr['BYDAY']); $last = $count-1; if ($count == 1) { ereg('([\-]{0,1})([0-9]{0,1})([A-Z]{2})',$arr['BYDAY'][0],$regs); list($junk,$sign,$day_num,$day_txt) = $regs; $num = two2threeCharDays($day_txt,false); if ($day_num != '') $by .= $day_num.' '; $by .= $daysofweekshort_lang[$num]; } else { foreach ($arr['BYDAY'] as $key => $day) { ereg('([\-]{0,1})([0-9]{0,1})([A-Z]{2})',$day,$regs); list($junk,$sign,$day_num,$day_txt) = $regs; $num = two2threeCharDays($day_txt,false); if ($day_num != '') $by .= $day_num.' '; if ($key == $last) $by .= $daysofweekshort_lang[$num]; else $by .= $daysofweekshort_lang[$num].', '; } } $by .= ' '; } return 'Every '.$int.' '.$freq.$times.$until.$by; } function getmicrotime() { list($usec, $sec) = explode(' ',microtime()); return ((float)$usec + (float)$sec); } ?>