if (is_dir($_filename)) { include 'ldp.php'; } else { $metafile = ''; $ldp_location = $_base; } $_data = file_get_contents('php://input'); 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');