Skip to content
Snippets Groups Projects
Commit f3627a75 authored by Aldo "xoen" Giambelluca's avatar Aldo "xoen" Giambelluca
Browse files

Using DB table prefix in 'inc/HTTP/WebDAV/Server/Filesyste.php'

parent 78cc98e4
No related branches found
No related tags found
No related merge requests found
...@@ -150,6 +150,9 @@ ...@@ -150,6 +150,9 @@
*/ */
function fileinfo($path) function fileinfo($path)
{ {
global $CONFIG_DBTABLEPREFIX;
$dbTableProperties = $CONFIG_DBTABLEPREFIX . 'properties';
// map URI path to filesystem path // map URI path to filesystem path
$fspath =$path; $fspath =$path;
...@@ -183,7 +186,7 @@ ...@@ -183,7 +186,7 @@
$info["props"][] = $this->mkprop("getcontentlength", OC_FILESYSTEM::filesize($fspath)); $info["props"][] = $this->mkprop("getcontentlength", OC_FILESYSTEM::filesize($fspath));
} }
// get additional properties from database // get additional properties from database
$query = "SELECT ns, name, value FROM properties WHERE path = '$path'"; $query = "SELECT ns, name, value FROM $dbTableProperties WHERE path = '$path'";
$res = OC_DB::select($query); $res = OC_DB::select($query);
while ($row = $res[0]) { while ($row = $res[0]) {
$info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]); $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
...@@ -392,6 +395,8 @@ ...@@ -392,6 +395,8 @@
*/ */
function DELETE($options) function DELETE($options)
{ {
global $CONFIG_DBTABLEPREFIX;
$dbTableProperties = $CONFIG_DBTABLEPREFIX . 'properties';
$path =$options["path"]; $path =$options["path"];
if (!OC_FILESYSTEM::file_exists($path)) { if (!OC_FILESYSTEM::file_exists($path)) {
...@@ -399,13 +404,13 @@ ...@@ -399,13 +404,13 @@
} }
if (OC_FILESYSTEM::is_dir($path)) { if (OC_FILESYSTEM::is_dir($path)) {
$query = "DELETE FROM properties WHERE path LIKE '".$this->_slashify($options["path"])."%'"; $query = "DELETE FROM $dbTableProperties WHERE path LIKE '".$this->_slashify($options["path"])."%'";
OC_DB::query($query); OC_DB::query($query);
OC_FILESYSTEM::delTree($path); OC_FILESYSTEM::delTree($path);
} else { } else {
OC_FILESYSTEM::unlink($path); OC_FILESYSTEM::unlink($path);
} }
$query = "DELETE FROM properties WHERE path = '$options[path]'"; $query = "DELETE FROM $dbTableProperties WHERE path = '$options[path]'";
OC_DB::query($query); OC_DB::query($query);
return "204 No Content"; return "204 No Content";
...@@ -432,6 +437,8 @@ ...@@ -432,6 +437,8 @@
function COPY($options, $del=false) function COPY($options, $del=false)
{ {
// TODO Property updates still broken (Litmus should detect this?) // TODO Property updates still broken (Litmus should detect this?)
global $CONFIG_DBTABLEPREFIX;
$dbTableProperties = $CONFIG_DBTABLEPREFIX . 'properties';
if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
return "415 Unsupported media type"; return "415 Unsupported media type";
...@@ -507,13 +514,13 @@ ...@@ -507,13 +514,13 @@
} }
$destpath = $this->_unslashify($options["dest"]); $destpath = $this->_unslashify($options["dest"]);
if (is_dir($source)) { if (is_dir($source)) {
$query = "UPDATE properties $query = "UPDATE $dbTableProperties
SET path = REPLACE(path, '".$options["path"]."', '".$destpath."') SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
WHERE path LIKE '".$this->_slashify($options["path"])."%'"; WHERE path LIKE '".$this->_slashify($options["path"])."%'";
OC_DB::query($query); OC_DB::query($query);
} }
$query = "UPDATE properties $query = "UPDATE $dbTableProperties
SET path = '".$destpath."' SET path = '".$destpath."'
WHERE path = '".$options["path"]."'"; WHERE path = '".$options["path"]."'";
OC_DB::query($query); OC_DB::query($query);
...@@ -554,7 +561,7 @@ ...@@ -554,7 +561,7 @@
} }
} }
$query = "INSERT INTO properties SELECT * FROM properties WHERE path = '".$options['path']."'"; $query = "INSERT INTO $dbTableProperties SELECT * FROM properties WHERE path = '".$options['path']."'";
} }
return ($new && !$existing_col) ? "201 Created" : "204 No Content"; return ($new && !$existing_col) ? "201 Created" : "204 No Content";
...@@ -569,6 +576,9 @@ ...@@ -569,6 +576,9 @@
function PROPPATCH(&$options) function PROPPATCH(&$options)
{ {
global $prefs, $tab; global $prefs, $tab;
global $CONFIG_DBTABLEPREFIX;
$dbTableProperties = $CONFIG_DBTABLEPREFIX . 'properties';
$msg = ""; $msg = "";
$path = $options["path"]; $path = $options["path"];
...@@ -580,10 +590,10 @@ ...@@ -580,10 +590,10 @@
$options["props"][$key]['status'] = "403 Forbidden"; $options["props"][$key]['status'] = "403 Forbidden";
} else { } else {
if (isset($prop["val"])) { if (isset($prop["val"])) {
$query = "REPLACE INTO properties SET path = '$options[path]', name = '$prop[name]', ns= '$prop[ns]', value = '$prop[val]'"; $query = "REPLACE INTO $dbTableProperties SET path = '$options[path]', name = '$prop[name]', ns= '$prop[ns]', value = '$prop[val]'";
error_log($query); error_log($query);
} else { } else {
$query = "DELETE FROM properties WHERE path = '$options[path]' AND name = '$prop[name]' AND ns = '$prop[ns]'"; $query = "DELETE FROM $dbTableProperties WHERE path = '$options[path]' AND name = '$prop[name]' AND ns = '$prop[ns]'";
} }
OC_DB::query($query); OC_DB::query($query);
} }
...@@ -601,6 +611,8 @@ ...@@ -601,6 +611,8 @@
*/ */
function LOCK(&$options) function LOCK(&$options)
{ {
global $CONFIG_DBTABLEPREFIX;
$dbTableLocks = $CONFIG_DBTABLEPREFIX . 'locks';
// get absolute fs path to requested resource // get absolute fs path to requested resource
$fspath = $options["path"]; $fspath = $options["path"];
...@@ -615,13 +627,13 @@ ...@@ -615,13 +627,13 @@
if (isset($options["update"])) { // Lock Update if (isset($options["update"])) { // Lock Update
$where = "WHERE path = '$options[path]' AND token = '$options[update]'"; $where = "WHERE path = '$options[path]' AND token = '$options[update]'";
$query = "SELECT owner, exclusivelock FROM locks $where"; $query = "SELECT owner, exclusivelock FROM $dbTableLocks $where";
$res = OC_DB::query($query); $res = OC_DB::query($query);
$row = OC_DB::fetch_assoc($res); $row = OC_DB::fetch_assoc($res);
OC_DB::free_result($res); OC_DB::free_result($res);
if (is_array($row)) { if (is_array($row)) {
$query = "UPDATE `locks` SET `expires` = '$options[timeout]', `modified` = ".time()." $where"; $query = "UPDATE `$dbTableLocks` SET `expires` = '$options[timeout]', `modified` = ".time()." $where";
OC_DB::query($query); OC_DB::query($query);
$options['owner'] = $row['owner']; $options['owner'] = $row['owner'];
...@@ -634,7 +646,7 @@ ...@@ -634,7 +646,7 @@
} }
} }
$query = "INSERT INTO `locks` $query = "INSERT INTO `$dbTableLocks`
SET `token` = '$options[locktoken]' SET `token` = '$options[locktoken]'
, `path` = '$options[path]' , `path` = '$options[path]'
, `created` = ".time()." , `created` = ".time()."
...@@ -656,7 +668,9 @@ ...@@ -656,7 +668,9 @@
*/ */
function UNLOCK(&$options) function UNLOCK(&$options)
{ {
$query = "DELETE FROM locks global $CONFIG_DBTABLEPREFIX;
$dbTableLocks = $CONFIG_DBTABLEPREFIX . 'locks';
$query = "DELETE FROM $dbTableLocks
WHERE path = '$options[path]' WHERE path = '$options[path]'
AND token = '$options[token]'"; AND token = '$options[token]'";
OC_DB::query($query); OC_DB::query($query);
...@@ -672,9 +686,11 @@ ...@@ -672,9 +686,11 @@
*/ */
function checkLock($path) function checkLock($path)
{ {
global $CONFIG_DBTABLEPREFIX;
$dbTableLocks = $CONFIG_DBTABLEPREFIX . 'locks';
$result = false; $result = false;
$query = "SELECT * $query = "SELECT *
FROM locks FROM $dbTableLocks
WHERE path = '$path' WHERE path = '$path'
"; ";
$res = OC_DB::select($query); $res = OC_DB::select($query);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment