webdav: fix icewind's new Filesystem.php version
This commit is contained in:
parent
45af5d78b5
commit
60d2f8de4e
|
@ -1,6 +1,8 @@
|
||||||
CREATE TABLE 'locks' (
|
CREATE TABLE 'locks' (
|
||||||
'token' VARCHAR(255) NOT NULL DEFAULT '',
|
'token' VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
'path' varchar(200) NOT NULL DEFAULT '',
|
'path' varchar(200) NOT NULL DEFAULT '',
|
||||||
|
'created' int(11) NOT NULL DEFAULT '0',
|
||||||
|
'modified' int(11) NOT NULL DEFAULT '0',
|
||||||
'expires' int(11) NOT NULL DEFAULT '0',
|
'expires' int(11) NOT NULL DEFAULT '0',
|
||||||
'owner' varchar(200) DEFAULT NULL,
|
'owner' varchar(200) DEFAULT NULL,
|
||||||
'recursive' int(11) DEFAULT '0',
|
'recursive' int(11) DEFAULT '0',
|
||||||
|
|
|
@ -78,11 +78,6 @@
|
||||||
$this->base = $this->_SERVER['DOCUMENT_ROOT'];
|
$this->base = $this->_SERVER['DOCUMENT_ROOT'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// establish connection to property/locking db
|
|
||||||
// mysql_connect($this->db_host, $this->db_user, $this->db_passwd) or die(mysql_error());
|
|
||||||
// mysql_select_db($this->db_name) or die(mysql_error());
|
|
||||||
// TODO throw on connection problems
|
|
||||||
|
|
||||||
// let the base class do all the work
|
// let the base class do all the work
|
||||||
parent::ServeRequest();
|
parent::ServeRequest();
|
||||||
}
|
}
|
||||||
|
@ -132,7 +127,7 @@
|
||||||
$options["path"] = $this->_slashify($options["path"]);
|
$options["path"] = $this->_slashify($options["path"]);
|
||||||
|
|
||||||
// try to open directory
|
// try to open directory
|
||||||
$handle = opendir($fspath);
|
$handle = @opendir($fspath);
|
||||||
|
|
||||||
if ($handle) {
|
if ($handle) {
|
||||||
// ok, now get all its contents
|
// ok, now get all its contents
|
||||||
|
@ -194,14 +189,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// get additional properties from database
|
// get additional properties from database
|
||||||
$query = "SELECT ns, name, value
|
$query = "SELECT ns, name, value FROM properties WHERE path = '$path'";
|
||||||
FROM {$this->db_prefix}properties
|
$res = OC_DB::query($query);
|
||||||
WHERE path = '$path'";
|
while ($row = OC_DB::fetch_assoc($res)) {
|
||||||
$res = mysql_query($query);
|
|
||||||
while ($row = mysql_fetch_assoc($res)) {
|
|
||||||
$info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
|
$info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
|
||||||
}
|
}
|
||||||
mysql_free_result($res);
|
OC_DB::free_result($res);
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +251,7 @@
|
||||||
*/
|
*/
|
||||||
function _mimetype($fspath)
|
function _mimetype($fspath)
|
||||||
{
|
{
|
||||||
if (is_dir($fspath)) {
|
if (@is_dir($fspath)) {
|
||||||
// directories are easy
|
// directories are easy
|
||||||
return "httpd/unix-directory";
|
return "httpd/unix-directory";
|
||||||
} else if (function_exists("mime_content_type")) {
|
} else if (function_exists("mime_content_type")) {
|
||||||
|
@ -516,16 +509,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$query = "DELETE FROM {$this->db_prefix}properties
|
$query = "DELETE FROM properties WHERE path LIKE '".$this->_slashify($options["path"])."%'";
|
||||||
WHERE path LIKE '".$this->_slashify($options["path"])."%'";
|
OC_DB::query($query);
|
||||||
mysql_query($query);
|
System::rm(array("-rf, $path"));
|
||||||
System::rm(array("-rf", $path));
|
|
||||||
} else {
|
} else {
|
||||||
unlink($path);
|
unlink($path);
|
||||||
}
|
}
|
||||||
$query = "DELETE FROM {$this->db_prefix}properties
|
$query = "DELETE FROM properties WHERE path = '$options[path]'";
|
||||||
WHERE path = '$options[path]'";
|
OC_DB::query($query);
|
||||||
mysql_query($query);
|
|
||||||
|
|
||||||
return "204 No Content";
|
return "204 No Content";
|
||||||
}
|
}
|
||||||
|
@ -624,16 +615,16 @@
|
||||||
}
|
}
|
||||||
$destpath = $this->_unslashify($options["dest"]);
|
$destpath = $this->_unslashify($options["dest"]);
|
||||||
if (is_dir($source)) {
|
if (is_dir($source)) {
|
||||||
$query = "UPDATE {$this->db_prefix}properties
|
$query = "UPDATE properties
|
||||||
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"])."%'";
|
||||||
mysql_query($query);
|
OC_DB::query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "UPDATE {$this->db_prefix}properties
|
$query = "UPDATE properties
|
||||||
SET path = '".$destpath."'
|
SET path = '".$destpath."'
|
||||||
WHERE path = '".$options["path"]."'";
|
WHERE path = '".$options["path"]."'";
|
||||||
mysql_query($query);
|
OC_DB::query($query);
|
||||||
} else {
|
} else {
|
||||||
if (is_dir($source)) {
|
if (is_dir($source)) {
|
||||||
$files = System::find($source);
|
$files = System::find($source);
|
||||||
|
@ -673,10 +664,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "INSERT INTO {$this->db_prefix}properties
|
$query = "INSERT INTO properties SELECT * FROM properties WHERE path = '".$options['path']."'";
|
||||||
SELECT *
|
|
||||||
FROM {$this->db_prefix}properties
|
|
||||||
WHERE path = '".$options['path']."'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($new && !$existing_col) ? "201 Created" : "204 No Content";
|
return ($new && !$existing_col) ? "201 Created" : "204 No Content";
|
||||||
|
@ -702,18 +690,12 @@
|
||||||
$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 {$this->db_prefix}properties
|
$query = "REPLACE INTO properties SET path = '$options[path]', name = '$prop[name]', ns= '$prop[ns]', value = '$prop[val]'";
|
||||||
SET path = '$options[path]'
|
error_log($query);
|
||||||
, name = '$prop[name]'
|
|
||||||
, ns= '$prop[ns]'
|
|
||||||
, value = '$prop[val]'";
|
|
||||||
} else {
|
} else {
|
||||||
$query = "DELETE FROM {$this->db_prefix}properties
|
$query = "DELETE FROM properties WHERE path = '$options[path]' AND name = '$prop[name]' AND ns = '$prop[ns]'";
|
||||||
WHERE path = '$options[path]'
|
|
||||||
AND name = '$prop[name]'
|
|
||||||
AND ns = '$prop[ns]'";
|
|
||||||
}
|
}
|
||||||
mysql_query($query);
|
OC_DB::query($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,18 +725,15 @@
|
||||||
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 {$this->db_prefix}locks $where";
|
$query = "SELECT owner, exclusivelock FROM locks $where";
|
||||||
$res = mysql_query($query);
|
$res = OC_DB:query($query);
|
||||||
$row = mysql_fetch_assoc($res);
|
$row = OC_DB:fetch_assoc($res);
|
||||||
mysql_free_result($res);
|
OC_DB:free_result($res);
|
||||||
|
|
||||||
if (is_array($row)) {
|
if (is_array($row)) {
|
||||||
$query = "UPDATE {$this->db_prefix}locks
|
$query = "UPDATE locks SET expires = '$options[timeout]', modified = ".time()." $where";
|
||||||
SET expires = '$options[timeout]'
|
OC_DB:query($query);
|
||||||
, modified = ".time()."
|
|
||||||
$where";
|
|
||||||
mysql_query($query);
|
|
||||||
|
|
||||||
$options['owner'] = $row['owner'];
|
$options['owner'] = $row['owner'];
|
||||||
$options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared";
|
$options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared";
|
||||||
$options['type'] = $row["exclusivelock"] ? "write" : "read";
|
$options['type'] = $row["exclusivelock"] ? "write" : "read";
|
||||||
|
@ -765,7 +744,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "INSERT INTO {$this->db_prefix}locks
|
$query = "INSERT INTO locks
|
||||||
SET token = '$options[locktoken]'
|
SET token = '$options[locktoken]'
|
||||||
, path = '$options[path]'
|
, path = '$options[path]'
|
||||||
, created = ".time()."
|
, created = ".time()."
|
||||||
|
@ -774,9 +753,9 @@
|
||||||
, expires = '$options[timeout]'
|
, expires = '$options[timeout]'
|
||||||
, exclusivelock = " .($options['scope'] === "exclusive" ? "1" : "0")
|
, exclusivelock = " .($options['scope'] === "exclusive" ? "1" : "0")
|
||||||
;
|
;
|
||||||
mysql_query($query);
|
OC_DB::query($query);
|
||||||
|
|
||||||
return mysql_affected_rows() ? "200 OK" : "409 Conflict";
|
return OC_DB::affected_rows() ? "200 OK" : "409 Conflict";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -787,12 +766,12 @@
|
||||||
*/
|
*/
|
||||||
function UNLOCK(&$options)
|
function UNLOCK(&$options)
|
||||||
{
|
{
|
||||||
$query = "DELETE FROM {$this->db_prefix}locks
|
$query = "DELETE FROM locks
|
||||||
WHERE path = '$options[path]'
|
WHERE path = '$options[path]'
|
||||||
AND token = '$options[token]'";
|
AND token = '$options[token]'";
|
||||||
mysql_query($query);
|
OC_DB::query($query);
|
||||||
|
|
||||||
return mysql_affected_rows() ? "204 No Content" : "409 Conflict";
|
return OC_DB::affected_rows() ? "204 No Content" : "409 Conflict";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -806,14 +785,14 @@
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
$query = "SELECT owner, token, created, modified, expires, exclusivelock
|
$query = "SELECT owner, token, created, modified, expires, exclusivelock
|
||||||
FROM {$this->db_prefix}locks
|
FROM locks
|
||||||
WHERE path = '$path'
|
WHERE path = '$path'
|
||||||
";
|
";
|
||||||
$res = mysql_query($query);
|
$res = OC_DB::query($query);
|
||||||
|
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$row = mysql_fetch_array($res);
|
$row = OC_DB::fetch_assoc($res);
|
||||||
mysql_free_result($res);
|
OC_DB::free_result($res);
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$result = array( "type" => "write",
|
$result = array( "type" => "write",
|
||||||
|
|
|
@ -268,6 +268,8 @@ class OC_CONFIG{
|
||||||
$query="CREATE TABLE 'locks' (
|
$query="CREATE TABLE 'locks' (
|
||||||
'token' VARCHAR(255) NOT NULL DEFAULT '',
|
'token' VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
'path' varchar(200) NOT NULL DEFAULT '',
|
'path' varchar(200) NOT NULL DEFAULT '',
|
||||||
|
'created' int(11) NOT NULL DEFAULT '0',
|
||||||
|
'modified' int(11) NOT NULL DEFAULT '0',
|
||||||
'expires' int(11) NOT NULL DEFAULT '0',
|
'expires' int(11) NOT NULL DEFAULT '0',
|
||||||
'owner' varchar(200) DEFAULT NULL,
|
'owner' varchar(200) DEFAULT NULL,
|
||||||
'recursive' int(11) DEFAULT '0',
|
'recursive' int(11) DEFAULT '0',
|
||||||
|
@ -308,6 +310,8 @@ CREATE TABLE 'users' (
|
||||||
CREATE TABLE IF NOT EXISTS `locks` (
|
CREATE TABLE IF NOT EXISTS `locks` (
|
||||||
`token` varchar(255) NOT NULL DEFAULT '',
|
`token` varchar(255) NOT NULL DEFAULT '',
|
||||||
`path` varchar(200) NOT NULL DEFAULT '',
|
`path` varchar(200) NOT NULL DEFAULT '',
|
||||||
|
`created` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`modified` int(11) NOT NULL DEFAULT '0',
|
||||||
`expires` int(11) NOT NULL DEFAULT '0',
|
`expires` int(11) NOT NULL DEFAULT '0',
|
||||||
`owner` varchar(200) DEFAULT NULL,
|
`owner` varchar(200) DEFAULT NULL,
|
||||||
`recursive` int(11) DEFAULT '0',
|
`recursive` int(11) DEFAULT '0',
|
||||||
|
|
Loading…
Reference in New Issue