if(strpos($query, "-") === FALSE) { $date = str_replace("_", " ", $query); $date = explode(" ", $date); $CurrentTime = time(); $units = array("minute", "minutes", "hour", "hours", "day", "days", "week", "weeks", "month", "months", "year", "years"); $months = array"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"); $maxdays = array("january" => "31", "february" => "28", "march" => "31", "april" => "30", "may" => "31", "june" => "30", "july" => "31", "august" => "31", "september" => "30", "october" => "31", "november" => "30", "december" => "31"); if(count($date) == 1) { if(!is_numeric($date[0])) $errors['date'] = "Error: Invalid Unix timestamp."; elseif(strlen($date[0]) != 10) $errors['date'] = "Error: Invalid timestamp length."; else $querystr .= "date:$date;"; } elseif(count($date) == 3) { if(in_array($date[0], $months)) { if(!is_numeric($date[1])) $errors['date'] = "Error: Invalid date.

Dates must use the following syntax:
1. (Number) (Hours/Days/Weeks/Months) Ago
2. (Month) (Numeric Date) (Numeric Year)
3. (Unix Timestamp)"; elseif(!is_numeric($date[2])) $errors['date'] = "Error: Since when are there non-numeric years?"; elseif($date[2] < 2007) $errors['date'] = "Error: Stop trying to search for shit from before Weedhat was even conceived."; elseif($maxdays[$date[0]] < $date[1]) { if($date[0] != "february") $errors['date'] = "Error: That month doesn't have that many days."; else { if((!LeapYear($date[2])) || ($date[1] > 29)) $errors['date'] = "Error: That month doesn't have that many days."; } } else $querystr .= "date:$date[0]_$date[1]_$date[2];"; } else { if(!is_numeric($date[0])) $errors['date'] = "Error: Invalid date.

Dates must use the following syntax:
1. (Number) (Hours/Days/Weeks/Months) Ago
2. (Month) (Numeric Date) (Numeric Year)
3. (Unix Timestamp)"; elseif(!in_array($date[1], $units)) $errors['date'] = "Error: Invalid date.

Dates must use the following syntax:
1. (Number) (Hours/Days/Weeks/Months) Ago
2. (Month) (Numeric Date) (Numeric Year)
3. (Unix Timestamp)"; elseif($date[2] != "ago") $errors['date'] = "Error: Invalid date.

Dates must use the following syntax:
1. (Number) (Hours/Days/Weeks/Months) Ago
2. (Month) (Numeric Date) (Numeric Year)
3. (Unix Timestamp)"; else $querystr .= "date:$date[0]_$date[1]_$date[2];"; } } }