Example #1
0
if ($_input == 'raw') {
    require_once 'if-match.php';
    file_put_contents($_filename, $_data, FILE_APPEND | LOCK_EX);
    httpStatusExit(201, 'Created');
}
$g = new Graph('', $_filename, '', $_base);
require_once 'if-match.php';
if ($_method == 'PATCH') {
    if ($_input == 'json' && ($g->patch_json($_data) || 1)) {
        librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message());
        $g->save();
        header('Triples: ' . $g->size());
        header("Link: <" . dirname($_base) . '/' . $metafile . ">; rel=meta", false);
        header('Location: ' . $ldp_location);
        httpStatusExit(201, 'Created');
    }
} elseif (!empty($_input) && ($g->append($_input, $_data) || 1)) {
    librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message());
    $g->save();
    header("Triples: " . $g->size(), false);
    header("Link: <" . $_base . $metafile . ">; rel=meta", false);
    header('Location: ' . $ldp_location);
    header('ETag: "' . md5_file($_filename) . '"');
    httpStatusExit(201, 'Created');
} elseif ($_content_type == 'application/sparql-update') {
    require_once 'SPARQL.php';
} else {
    librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message());
    header('Accept-Post: ' . implode(',', $_content_types));
    httpStatusExit(406, 'Content-Type (' . $_content_type . ') Not Acceptable');
}
Example #2
0
    $contents = $contents_chunks[$p - 1];
    $complement = '?p=' . (string) $p;
}
// add paging headers
// set last page
header("Link: <" . $_base . "?p=" . (string) $pages . ">; rel='last'", false);
if ($p > 1) {
    header("Link: <" . $_base . "?p=" . (string) ($p - 1) . ">; rel='prev'", false);
}
if ($p < $pages) {
    header("Link: <" . $_base . "?p=" . (string) ($p + 1) . ">; rel='next'", false);
    header("HTTP/1.1 333 Returning Related", false, 333);
}
// List LDPC info
$ldpc = "@prefix ldp: <http://www.w3.org/ns/ldp#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix p: <http://www.w3.org/ns/posix/stat#> ." . "<" . $_base . "> a ldp:Container, ldp:BasicContainer, p:Directory ; " . "p:mtime " . filemtime($_filename) . " ;" . "p:size " . filesize($_filename) . " ;";
$g->append('turtle', $ldpc);
// add extra LDPC metadata from .meta.<LDPC>
$meta_uri = dirname($_base) . '/.meta.' . basename($_base);
$meta_file = dirname($_filename) . '/.meta.' . basename($_filename);
$mg = new Graph('', $meta_file, '', $meta_uri);
if ($mg->size() > 0) {
    // specific authorization
    $q = 'SELECT * WHERE { <' . $_base . '> ?p ?o }';
    $s = $mg->SELECT($q);
    $res = $s['results']['bindings'];
    if (isset($res) && count($res) > 0) {
        foreach ($res as $t) {
            $g->append_objects($_base, $t['p']['value'], array($t['o']));
        }
    }
}
Example #3
0
        httpStatusExit(403, 'Forbidden');
    }
}
// check quota
if (check_quota($_root, $_SERVER["CONTENT_LENGTH"]) == false) {
    httpStatusExit(507, 'Insufficient Storage');
}
// action
$d = dirname($_filename);
if (!file_exists($d)) {
    mkdir($d, 0777, true);
}
$_data = file_get_contents('php://input');
if ($_input == 'raw') {
    require_once 'if-match.php';
    file_put_contents($_filename, $_data);
    httpStatusExit(201, 'Created');
}
$g = new Graph('', $_filename, '', $_base);
require_once 'if-match.php';
$g->truncate();
if (!empty($_input) && $g->append($_input, $_data)) {
    librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message());
    $g->save();
    header('ETag: "' . md5_file($_filename) . '"');
    httpStatusExit(201, 'Created');
} else {
    librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message());
    header('Accept-Post: ' . implode(',', $_content_types));
    httpStatusExit(406, 'Content-Type (' . $_content_type . ') Not Acceptable');
}