'."\n". ''."\n". ''."\n". ''."\n". ''."\n". ''; $search_started = getmicrotime(); if ($search_valid) { $format_search_arr = format_search($query); if (!$format_search_arr[0]) { $formatted_search = ''.$no_query_lang.''; } else { $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_lang.''; } $search_ended = getmicrotime(); $search_took = number_format(($search_ended-$search_started),3); include (BASE.'includes/header.inc.php'); ?>
\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'])) { 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 "
\"
\n"; 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"; } } echo "
\"$exception_lang: $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_lang:$recur
$description_lang:$description
\n"; echo "
\"
'; echo $no_results_lang; echo '
 
'.sprintf($search_took_lang,$search_took).'

'; ?>
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]; if (!$needle_arr[0]) return false; if ((sizeof($and_arr) == 0) && (sizeof($or_arr) == 0) && (sizeof($not_arr) == 0)) return false; // compare lowercase versions of the strings $haystack = strtolower($haystack); // check against the NOT foreach($not_arr as $s) { if (is_string(strstr($haystack,$s)) == true) { return false; } } // check against the AND foreach($and_arr as $s) { if (is_string(strstr($haystack,$s)) == 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 (is_string(strstr($haystack,substr($s,1))) == false) { $is_false = false; break; } } elseif (is_string(strstr($haystack,$s)) == 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 $format_recur_lang, $monthsofyear_lang, $daysofweek_lang; $d = $format_recur_lang['delimiter']; $int = $arr['INTERVAL']; $tmp = (($int == '1') ? 0 : 1); $freq = $arr['FREQ']; $freq = $format_recur_lang[$freq][$tmp]; if (isset($arr['COUNT'])) $for = str_replace('%int%',$arr['COUNT'],$format_recur_lang['count']); elseif (isset($arr['UNTIL'])) $for = str_replace('%date%',$arr['UNTIL'], $format_recur_lang['until']); else $for = ''; $print = $format_recur_lang['start']; $print = str_replace('%int%', $int, $print); $print = str_replace('%freq%', $freq, $print); $print = str_replace('%for%', $for, $print); if (isset($arr['BYMONTH'])) { $list = ''; $last = count($arr['BYMONTH']) - 1; foreach ($arr['BYMONTH'] as $key => $month) { if ($key == $last) $list .= $monthsofyear_lang[($month-1)]; else $list .= $monthsofyear_lang[($month-1)].$d; } $print .= '
'."\n"; $print .= str_replace('%list%', $list, $format_recur_lang['bymonth']); } if (isset($arr['BYMONTHDAY'])) { $list = ''; if ($arr['BYMONTHDAY'][(count($arr['BYMONTHDAY']) - 1)] == '0') unset($arr['BYMONTHDAY'][$last]); $last = count($arr['BYMONTHDAY']) - 1; foreach ($arr['BYMONTHDAY'] as $key => $day) { ereg('(-{0,1})([0-9]{1,2})',$day,$regs); list($junk,$sign,$day) = $regs; if ($sign != '') $list .= $sign; if ($key == $last) $list .= $day; else $list .= $day.$d; } $print .= '
'."\n"; $print .= str_replace('%list%', $list, $format_recur_lang['bymonthday']); } if (isset($arr['BYDAY'])) { $list = ''; $last = count($arr['BYDAY']) - 1; 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 ($sign != '') $list .= $sign; if ($day_num != '') $list .= $day_num.' '; if ($key == $last) $list .= $daysofweek_lang[$num]; else $list .= $daysofweek_lang[$num].$d; } $print .= '
'."\n"; $print .= str_replace('%list%', $list, $format_recur_lang['byday']); } return $print; } function getmicrotime() { list($usec, $sec) = explode(' ',microtime()); return ((float)$usec + (float)$sec); } ?>