예제 #1
0
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (ATCExceptionDBError $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (ATCExceptionDBConn $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (ATCException $e) {
        header("HTTP/1.0 400 Bad Request");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    } catch (Exception $e) {
        header("HTTP/1.0 500 Internal Server Error");
        echo 'Caught exception: ', $e->getMessage(), "\n";
    }
}
$terms = $ATC->get_terms();
if (!isset($_GET['termstart'])) {
    $targettime = time();
} else {
    $targettime = strtotime($_GET['termstart']);
}
// Try to find our beginning/end dates for a term that's been requested
foreach ($terms as $term) {
    if ($term->startdate <= $targettime && $term->enddate + (24 + 60 + 60) >= $targettime) {
        $termstart = date('Y-m-d', $term->startdate);
        $termend = date('Y-m-d', $term->enddate);
        break;
    }
}
// Default to all this year if we can't find a term start time matching what we asked for.
if (!isset($termstart)) {