예제 #1
0
require 'setup.php';
require_once 'lda-cache.class.php';
require_once 'lda-request.class.php';
require_once 'lda-response.class.php';
require_once 'graphs/configgraph.class.php';
require_once 'responses/Response304.class.php';
Logger::configure("puelia.logging.properties");
$HttpRequestFactory = new HttpRequestFactory();
if (function_exists('memcache_connect')) {
    $MemCacheObject = new LinkedDataApiCache();
    $HttpRequestFactory->set_cache($MemCacheObject);
}
$Request = new LinkedDataApiRequest();
header("Access-Control-Allow-Origin: *");
define("CONFIG_PATH", '/api-config');
define("CONFIG_URL", $Request->getBaseAndSubDir() . CONFIG_PATH);
logDebug("Request URI: " . $Request->getUri());
if (rtrim($Request->getPath(), '/') == $Request->getInstallSubDir()) {
    header("Location: " . CONFIG_URL, true, 303);
    exit;
}
if (defined("PUELIA_SERVE_FROM_CACHE") and !$Request->hasNoCacheHeader() and $cachedResponse = LinkedDataApiCache::hasCachedResponse($Request)) {
    logDebug("Found cached response");
    if (isset($Request->ifNoneMatch) && $cachedResponse->eTag == $Request->ifNoneMatch) {
        logDebug("ETag matched, returning 304");
        $Response = new Response304($cachedResponse);
    } else {
        if (isset($Request->ifModifiedSince) && $cachedResponse->generatedTime <= $Request->ifModifiedSince) {
            logDebug("Last modified date matched, returning 304");
            $Response = new Response304($cachedResponse);
        } else {