示例#1
0
        // SPARQL server did not respond, send a 503.
        header("HTTP/1.1 503 Service Unavailable");
        readfile("errors/503.html");
    }
    die;
} else {
    // Check that the requested resource exists
    $query = 'SELECT ?type WHERE { <' . $bases[$_GET["src"]] . $_GET["q"] . '> a ?type }';
    $res = @file_get_contents(ENDPOINT . '?query=' . urlencode($query));
    if (1 == preg_match("/<results>\\s*<\\/results>/", $res)) {
        header("HTTP/1.1 404 Not Found");
        readfile("http://tw.rpi.edu/web/404notfound");
        die;
    }
    // Obtain best mime type
    $mime = getBestSupportedMimeType(array("application/rdf+xml", "text/html", "application/xhtml+xml", "text/n3", "text/plain"));
    fprintf($logger, "mime = {$mime}\n");
    if ($mime == "application/rdf+xml") {
        // Handle application/rdf+xml Mime Type
        if ($output == "rdf") {
            // output=rdf, so the extension on the URI was .rdf
            // Set content type and DESCRIBE the resource
            header("Content-Type: application/rdf+xml");
            $query = 'DESCRIBE <' . $bases[$_GET["src"]] . $_GET["q"] . '>';
            if (FALSE === @readfile(ENDPOINT . "?query=" . urlencode($query))) {
                // SPARQL endpoint did not respond, send 503
                header("HTTP/1.1 503 Service Unavailable");
                readfile("errors/503.html");
                die;
            }
        } else {
示例#2
0
}
// Perform content negotiation
if (!isset($_GET['uri'])) {
    header('HTTP/1.0 404 Not Found');
    echo "<h1>404 Not Found</h1>";
    echo "No uri";
    echo "The page that you have requested could not be found.";
    exit;
}
if (isset($_GET['type'])) {
    $type = $_GET['type'];
    if ($type != 'rdf' && $type != 'ttl' && $type != 'nt' && $type != 'html') {
        $type = 'html';
    }
} else {
    $accept_type = getBestSupportedMimeType(array('application/rdf+xml', 'text/turtle', 'application/xhtml+xml', 'text/html', 'text/plain'));
    if ($accept_type == 'application/rdf+xml') {
        $type = 'rdf';
    } elseif ($accept_type == 'text/turtle') {
        $type = 'ttl';
    } elseif ($accept_type == 'text/plain') {
        $type = 'nt';
    } else {
        $type = 'html';
    }
}
$prefix = "http://lemon-model/net/lexica/de-gaap/en";
if (file_exists($_GET['uri'] . "." . $type)) {
    include $_GET['uri'] . "." . $type;
    exit;
} else {
示例#3
0
        echo "<td><a href=\"" . $uri . "\">" . $name . "</a></td>";
        echo "<td><a href=\"" . $doc["creator"] . "\">" . $doc["first"] . " " . $doc["last"] . "</a></td>";
        $time = strtotime($doc["modified"]);
        echo "<td>" . date("h:i a \\o\\n M j, Y", $time) . "</td>";
        $time = strtotime($doc["created"]);
        echo "<td>" . date("h:i a \\o\\n M j, Y", $time) . "</td>";
        echo "</tr>";
    }
    ?>
</table>
<?php 
} else {
    // Handle GET method. For now we don't support any other method
    if ($_SERVER["REQUEST_METHOD"] == "GET") {
        // Obtain best possible Accept type
        $type = getBestSupportedMimeType(array("application/rdf+xml", "*/*"));
        $fileType = exec("file -biL 'files/" . $requestedFile . "'");
        if ($type == "application/rdf+xml" || isset($_GET["mode"]) && $_GET["mode"] == "rdf") {
            // Handle application/rdf+xml as a separate condition
            $query = "";
            // Test if this is the 'current' symlink, look up the original file
            // and use it as the URI in the SPARQL request
            if (is_link('files/' . $requestedFile)) {
                $requestedFile = readlink('files/' . $requestedFile);
                $perl = "/" . preg_replace("/\\//", "\\/", getRoot()) . "files\\//";
                $requestedFile = preg_replace($perl, "", $requestedFile);
            }
            // Build the SPARQL query
            $base = getBase();
            $query = "PREFIX dc: <http://purl.org/dc/terms/> DESCRIBE <{$base}" . $requestedFile . "> ?x WHERE { <{$base}" . $requestedFile . "> dc:creator ?x }";
            // Return SPARQL result