<?php /* * Copyright (C) 2013 RWW.IO * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is furnished * to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ require_once 'runtime.php'; $acc = urldecode($_REQUEST['domain']); $domain = $_ENV['CLOUD_DATA'] . '/' . $acc; $empty = is_dir_empty($domain); if ($empty == true) { httpStatusExit(404, 'Not Found'); } else { httpStatusExit(200, 'OK'); } exit;
$dirindex = false; break; } } if ($dirindex) { include_once 'index.rdf.php'; } } } // output raw if ($_output == 'raw') { if ($_output_type) { header("Content-Type: {$_output_type}"); } if (!file_exists($_filename)) { httpStatusExit(404, 'Not Found', '403-404.php'); } // add meta relation if ($_options->linkmeta) { header("Link: <" . $_metabase . $_metaname . ">; rel=meta", false); } // caching for files $expires = 60 * 60; // 1 hour header("Pragma: public"); header("Cache-Control: max-age=" . $expires, true); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); if ($_method == 'GET') { readfile($_filename); } exit;
} else { $exists = file_exists($_filename); if ($exists) { $etag = is_dir($_filename) ? md5_dir($_filename) : md5_file($_filename); if (strlen($etag)) { $etag = trim(array_shift(explode(' ', $etag))); } } else { $etag = ''; } } //echo "ETag: ".$etag; //echo "\nExists: ".$exists; //echo "\nIf-Match: ".$if_match; //echo "\nIf-None-Match: ".$if_none_match; if (strlen($if_match)) { $fail = $if_match == '*' && !$exists || $if_match != '*' && $if_match != $etag; } else { $fail = $if_none_match == '*' && $exists || $if_none_match != '*' && $if_none_match == $etag; } //echo "\nFail: ".$fail; //echo "\nMethod: ".$_method_type; if ($fail) { if ($_method_type == 'read') { httpStatusExit(304, 'Not Modified'); } elseif ($_method_type == 'write') { header("Link: <" . $_base . ">; rel=describedby", false); httpStatusExit(412, 'Precondition Failed'); } } }
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'); }
} elseif (isset($i_s)) { $any_s = $i_s; } if (!is_null($any_s)) { $g = new Graph('', $_filename, '', $_SERVER['SCRIPT_URI']); $r = strlen($any_s) ? $g->remove_any($any_s) : 0; header('Triples: ' . $r); if ($r) { $g->save(); } exit; } if (is_dir($_filename)) { if ($_options->recursive) { rrmdir($_filename); } else { rmdir($_filename); } } elseif (file_exists($_filename)) { unlink($_filename); } else { $g = new Graph('', $_filename, '', ''); if ($g->exists()) { $g->delete(); } else { httpStatusExit(404, 'Not Found'); } } if (file_exists($_filename)) { httpStatusExit(409, 'Conflict'); }
<?php /* MKCOL.php * service HTTP MKCOL controller */ require_once 'runtime.php'; // permissions if (empty($_user)) { httpStatusExit(401, 'Unauthorized'); } if ($_wac->can('Write') == false) { httpStatusExit(403, 'Forbidden'); } // check quota (avoids making lots of dirs if out of space) if (check_quota($_root, 10) == false) { httpStatusExit(507, 'Insufficient Storage'); } // action @mkdir($_filename, 0777, true); header("Link: <" . $_metabase . $_metaname . ">; rel=meta", false); httpStatusExit(201, 'Created');