16 require_once
"DAV/Class.ServerDav.php";
56 private $folder_max_item =
'ALL';
71 $this->db_res = pg_connect($this->db_webdav) or die(
"connection error");
73 parent::__construct();
86 foreach (apache_request_headers() as $key =>
$value) {
87 if (stristr($key,
"litmus")) {
88 error_log(
"Litmus test $value");
89 header(
"X-Litmus-reply: " .
$value);
95 parent::ServeRequest();
120 $fspath = $options[
"path"];
122 error_log(
" >PROPFIND depth:" . $options[
"depth"]);
125 $files[
"files"] = array();
128 if (!empty($options[
"depth"])) {
130 $options[
"path"] = $this->
_slashify($options[
"path"]);
133 $files[
"files"] = $freefiles;
136 $freefiles = $this->
readfolder($fspath,
true);
137 $files[
"files"] = $freefiles;
140 if (count($files[
"files"]) == 0)
return false;
142 error_log(
"PROPFIND OK");
148 include_once (
'FDL/Class.SearchDoc.php');
153 if (strtolower($fspath) ==
"/freedav") {
155 $info[
"props"] = array();
156 $info[
"props"][] = $this->
mkprop(
"resourcetype",
"collection");
157 $info[
"props"][] = $this->
mkprop(
"getcontenttype",
"httpd/unix-directory");
158 $info[
"props"][] = $this->
mkprop(
"displayname", $fspath);
159 $info[
"path"] = $fspath;
166 if ($fld->isAlive()) {
169 if (($fld->doctype ==
'D') || ($fld->doctype ==
'S')) $dpath = $this->
_slashify($fspath);
170 else $dpath = $fspath;
174 $s->dirid = $fld->initid;
176 $s->setObjectReturn();
178 if (
$s->count() > 0) {
179 while (
$doc =
$s->getNextDoc()) {
180 $files = array_merge($files, $this->
docpropinfo(
$doc, $fspath,
false));
190 private static function logArray(
$a, $level = 0)
193 foreach (
$a as $k => $v) {
194 error_log(str_pad(
'.', $level * 3) .
"$k=>" . self::logArray($v, $level + 1));
197 error_log(str_pad(
'.', $level * 3) .
$a);
206 if (preg_match(
'/\/vid-([0-9]+)-([0-9]+)-[a-f0-9]+$/', $fspath, $reg)) {
215 }
else if (preg_match(
'/\/vid-([0-9]+)-([0-9]+)/', $fspath, $reg)) {
216 include_once (
'FDL/Lib.Vault.php');
221 $fsbase = basename($fspath);
222 if (
$info->name == $fsbase) {
230 if (!
seems_utf8($fspath)) $fspath = utf8_encode($fspath);
231 $query = sprintf(
"SELECT value FROM dav.properties WHERE name='fid' and path = '%s'", pg_escape_string($fspath));
233 $res = pg_query($this->db_res,
$query);
234 while ($row = pg_fetch_assoc($res)) {
235 $fid = $row[
"value"];
238 pg_free_result($res);
250 $fileAttributes =
$doc->GetFileAttributes();
252 foreach ($fileAttributes as $fileAttribute) {
253 if ($fileAttribute->getOption(
'hideindav') ==
'yes') {
256 $result =
$doc->vault_properties($fileAttribute);
257 if (count($result) > 0 && is_array($result[0])) {
258 foreach ($result as $tmp) {
259 $state = intval($tmp[
"teng_state"]);
260 if ($state == 0 || $state == 1) {
273 $fspath = $this->base .
$path;
279 if (
$doc->id == $this->racine)
$doc->title =
'';
283 if ((
$doc->doctype ==
'D') || (
$doc->doctype ==
'S')) {
286 $info[
"props"] = array();
287 $info[
"props"][] = $this->
mkprop(
"resourcetype",
"collection");
288 $info[
"props"][] = $this->
mkprop(
"getcontenttype",
"httpd/unix-directory");
289 $info[
"props"][] = $this->
mkprop(
"displayname", strtr(
$doc->title,
"/",
"-"));
298 $query = sprintf(
"SELECT ns, name, value FROM dav.properties WHERE path = '%s'", pg_escape_string(
$path));
299 $res = pg_query($this->db_res,
$query);
300 while ($row = pg_fetch_assoc($res)) {
301 $info[
"props"][] = $this->
mkprop($row[
"ns"], $row[
"name"], $row[
"value"]);
303 pg_free_result($res);
305 if (($firstlevel) || (
$doc->title !=
"")) {
307 $query = sprintf(
"delete from dav.properties where path= '%s' and name= 'fid'", pg_escape_string($this->
_unslashify(
$info[
"path"])));
309 pg_query($this->db_res,
$query);
311 $query = sprintf(
"INSERT INTO dav.properties (path, name, ns, value) values ('%s', 'fid', '%s', '%s')", pg_escape_string($this->
_unslashify(
$info[
"path"])) , pg_escape_string($ns) , pg_escape_string(
$doc->initid));
313 pg_query($this->db_res,
$query);
318 $afiles = $this->GetFilesProperties(
$doc);
324 foreach ($afiles as $afile) {
326 $info[
"props"][] = $this->
mkprop(
"resourcetype",
"");
327 $aname = strtr($afile[
"name"],
"/",
"-");
329 if ((!$firstlevel) || ($aname == $bpath)) {
330 if ($firstlevel)
$info[
"path"] = $dpath . $aname;
335 $info[
"props"][] = $this->
mkprop(
"displayname", $aname);
339 $info[
"props"][] = $this->
mkprop(
"getcontentlength", intval($afile[
"size"]));
341 $query = sprintf(
"SELECT ns, name, value FROM dav.properties WHERE path = '%s'", pg_escape_string($this->
_unslashify(
$info[
"path"])));
342 $res = pg_query($this->db_res,
$query);
343 while ($row = pg_fetch_assoc($res)) {
344 $info[
"props"][] = $this->
mkprop($row[
"ns"], $row[
"name"], $row[
"value"]);
346 pg_free_result($res);
351 $query = sprintf(
"delete from dav.properties where path= '%s' and name= 'fid'", pg_escape_string($this->
_unslashify(
$info[
"path"])));
352 pg_query($this->db_res,
$query);
354 $query = sprintf(
"INSERT INTO dav.properties (path, name, ns, value) values ('%s', 'fid', '%s', '%s')", pg_escape_string($this->
_unslashify(
$info[
"path"])) , pg_escape_string($ns) , pg_escape_string(
$doc->initid));
355 pg_query($this->db_res,
$query);
383 if (preg_match(
"/\/vid-([^\/]*)\/(.*)/",
$path, $reg)) {
390 $info[
"props"] = array();
391 $info[
"props"][] = $this->
mkprop(
"resourcetype",
"collection");
392 $info[
"props"][] = $this->
mkprop(
"getcontenttype",
"httpd/unix-directory");
398 $info[
"props"][] = $this->
mkprop(
"creationdate", time());
399 $info[
"props"][] = $this->
mkprop(
"getlastmodified", time());
404 if ($withfile || $onlyfile) {
408 $afiles = $this->GetFilesProperties(
$doc);
414 foreach ($afiles as $afile) {
415 $aname = $afile[
"name"];
417 if ((!$onlyfile) || ($aname == $onlyfile)) {
420 $info[
"props"][] = $this->
mkprop(
"resourcetype",
"");
422 $info[
"props"][] = $this->
mkprop(
"displayname", $aname);
428 $info[
"props"][] = $this->
mkprop(
"getcontentlength", intval($afile[
"size"]));
432 $info[
"props"][] = $this->
mkprop(
"urn:schemas-microsoft-com:",
"Win32FileAttributes",
"00000001");
456 if (
$path ===
false) {
457 $path = getenv(
"PATH");
460 if (!strncmp(PHP_OS,
"WIN", 3)) {
466 $check_fn =
"file_exists";
472 $check_fn =
"is_executable";
475 foreach (explode(PATH_SEPARATOR,
$path) as
$dir) {
477 if (!file_exists($dir))
continue;
478 if (!is_dir($dir))
continue;
480 foreach ($exts as
$ext) {
481 if ($check_fn(
"$dir/$name" . $ext))
return true;
495 return strtok(trim(shell_exec(sprintf(
"file -ib %s", escapeshellarg($fspath)))) ,
';');
496 if (@is_dir($fspath)) {
498 return "httpd/unix-directory";
499 }
else if (function_exists(
"mime_content_type")) {
501 $mime_type = mime_content_type($fspath);
505 $fp = popen(
"file -i '$fspath' 2>/dev/null",
"r");
512 if (!strncmp($reply,
"$fspath: ", strlen($fspath) + 2)) {
513 $reply = substr($reply, strlen($fspath) + 2);
515 if (preg_match(
'/^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*/', $reply, $matches)) {
516 $mime_type = $matches[0];
521 if (empty($mime_type)) {
535 switch (strtolower(strrchr($this->
mybasename($fspath) ,
"."))) {
537 $mime_type =
"text/html";
541 $mime_type =
"image/gif";
545 $mime_type =
"image/jpeg";
549 $mime_type =
"application/octet-stream";
564 error_log(
"---------->GET :" . $options[
"path"]);
565 include_once (
"FDL/Class.Doc.php");
567 $fspath = $this->base . $options[
"path"];
571 if (!
$doc->isAlive()) {
575 $afiles = $this->GetFilesProperties(
$doc);
577 $bpath = $options[
"path"];
578 if (!
seems_utf8($bpath)) $bpath = utf8_encode($bpath);
581 foreach ($afiles as $afile) {
582 $path = $afile[
"name"];
584 if (($vid == $afile[
"vid"]) || (
$path == $bpath)) {
585 error_log(
"GET FOUND:" .
$path .
'-' . $afile[
"path"]);
586 $fspath = $afile[
"path"];
591 if (!file_exists($fspath))
return false;
593 if (is_dir($fspath)) {
594 return $this->
GetDir($fspath, $options);
597 $options[
'mimetype'] = $this->
_mimetype($fspath);
602 $options[
'mtime'] = filemtime($fspath);
604 $options[
'size'] = filesize($fspath);
606 $options[
'stream'] = fopen($fspath,
"r");
608 header(
"Cache-control: no-cache");
609 header(
"Pragma: no-cache");
610 error_log(
"GET NO CACHE :" . $options[
"path"]);
625 echo
"<html><head><title>Index of " . htmlspecialchars($options[
'path']) .
"</title></head>\n";
627 echo
"<h1>Index of " . htmlspecialchars($options[
'path']) .
"</h1>\n";
629 echo
"<pre>WebDAV Server: HTML view is not implemented yet";
647 error_log(
"---------->PUT :" . $options[
"path"]);
648 include_once (
"FDL/Class.Doc.php");
651 if (!
seems_utf8($bpath)) $bpath = utf8_encode($bpath);
654 $stat =
"204 No Content";
655 $options[
"new"] =
false;
659 if (
$doc->doctype ==
'C') {
663 $doc->saveVaultFile($vid, $options[
"stream"]);
665 $afiles =
$doc->GetFileAttributes();
671 foreach ($afiles as $afile) {
672 if ($afile->getOption(
'hideindav') ==
'yes') {
676 if ($afile->inArray()) {
677 $tval =
$doc->getMultipleRawValues($afile->id);
678 foreach ($tval as $k => $v) {
679 $fnames[$k] =
$doc->vault_filename($afile->id,
false, $k);
681 }
else $fnames[-1] =
$doc->vault_filename($afile->id);
682 foreach ($fnames as $k => $fname) {
684 if ($fname == $bpath) {
686 $doc->saveFile($afile->id, $options[
"stream"], $bpath, $k);
697 error_log(
"PUT " . $this->
type);
698 if ($this->
type ==
'freedav') {
699 error_log(
" CANCEL PUT :" . $options[
"path"]);
703 $options[
"new"] =
true;
704 $stat =
"201 Created";
705 if ($options[
"new"]) {
706 $dir = dirname($options[
"path"]);
709 $err = $fld->canModify();
714 if ($ndoc && $ndoc->fromid) {
715 $fa = $ndoc->GetFirstFileAttributes();
717 $ndoc->saveFile($fa->id, $options[
"stream"], $bpath);
720 $err = $ndoc->postStore();
721 $err = $ndoc->Modify();
722 error_log(
"PUT NEW FILE:" . $fa->id .
"-" . $ndoc->id);
724 $err = $fld->addFile($ndoc->initid);
725 error_log(
"PUT ADD IN FOLDER:" .
$err . $fld->id .
"UID:" . ($fld->userid));
729 $err =
"not allowed";
735 error_log(
" CREATE PUT OK :" . $options[
"path"]);
737 error_log(
" CREATE PUT KO : $err:" . $options[
"path"]);
739 if (
$err !=
"") $stat =
false;
752 error_log(
"---------- >MKCOL :" . $options[
"path"]);
754 include_once (
"FDL/Class.Doc.php");
756 if (!empty(
$_SERVER[
"CONTENT_LENGTH"])) {
757 return "415 Unsupported media type";
765 if ((!$nfld) || (!$nfld->fromid))
return "403 Forbidden : $err";
767 $nfld->setTitle($nreptitle);
770 $err = $fld->AddFile($nfld->initid);
771 error_log(
"NEW FLD:" . $nfld->initid);
790 return "403 Forbidden : $err";
793 return (
"201 Created");
803 error_log(
"---------- >DELETE :" . $options[
"path"]);
805 if ($this->
type ==
'freedav') {
806 $err = sprintf(
"unsupported DELETE method with freedav access.");
807 error_log(sprintf(
"---------- > %s",
$err));
808 return "403 Forbidden: $err";
811 include_once (
"FDL/Class.Doc.php");
815 if (!
$doc->isAlive()) {
816 return "404 Not found";
818 if (
$doc->doctype ==
'D') {
822 return "403 Forbidden:$err";
825 $query = sprintf(
"DELETE FROM dav.properties WHERE path LIKE '%s%%'", pg_escape_string($this->
_slashify($options[
"path"])));
826 pg_query($this->db_res,
$query);
829 if (
$doc->isLocked()) {
834 return "403 Forbidden:$err";
838 return "403 Forbidden:$err";
840 $query = sprintf(
"DELETE FROM dav.properties WHERE name='fid' and value='%s'", pg_escape_string(
$doc->initid));
842 pg_query($this->db_res,
$query);
845 return "204 No Content";
855 error_log(
"---------- >MOVE :" . $options[
"path"] .
"->" . $options[
"dest"]);
857 if (isset($options[
"dest_url"])) {
858 return "502 bad gateway";
861 include_once (
"FDL/Class.Doc.php");
863 $pdirsource = $this->
_unslashify(dirname($options[
"path"]));
866 $srcid = $this->
path2id($psource);
869 $err = $src->canEdit();
874 $destid = $this->
path2id($pdest);
876 $pdirdest = $this->
_unslashify(dirname($options[
"dest"]));
877 $dirdestid = $this->
path2id($pdirdest);
878 $ppdest = new_doc($this->
db_freedom, $dirdestid);
882 if (
$dest->doctype ==
'D') {
884 return "502 bad gateway";
887 error_log(
"DELETE FILE : $destid:" .
$dest->title);
891 $query = sprintf(
"DELETE FROM dav.properties WHERE name='fid' and value='%s'", pg_escape_string(
$dest->initid));
893 pg_query($this->db_res,
$query);
895 $err = $ppdest->addFile($srcid);
898 $psrcid = $this->
path2id($pdirsource);
900 if ($psrc->isAlive()) {
901 $err = $psrc->delFile($srcid);
904 $src->addHistoryEntry(sprintf(_(
"Move file from %s to %s") , ($psrc->title) , ($ppdest->title)));
905 $query =
"DELETE FROM dav.properties WHERE path = '$psource'";
911 if ($bdest != $bsource) {
912 error_log(
" RENAMETO2 : $bdest");
913 $src->setTitle($bdest);
914 $err = $src->modify();
918 $query = sprintf(
"DELETE FROM dav.properties WHERE path = '%s'", pg_escape_string($psource));
920 pg_query($this->db_res,
$query);
922 error_log(
" RENAMETO : $bdest : $err");
926 if ($pdirsource != $pdirdest) {
928 $err = $ppdest->addFile($srcid);
932 $psrcid = $this->
path2id($pdirsource);
934 if ($psrc->isAlive()) {
935 $err = $psrc->delFile($srcid);
937 $src->addHistoryEntry(sprintf(_(
"Move file from %s to %s") , ($psrc->title) , ($ppdest->title)));
938 $query = sprintf(
"DELETE FROM dav.properties WHERE path = '%s'", pg_escape_string($psource));
939 pg_query($this->db_res,
$query);
943 error_log(
"MOVE TO PARENT2 FOLDER : $dirdestid:" .
$err);
946 if ($bdest != $bsource) {
947 if ($src->doctype ==
'D') {
948 $src->setTitle($bdest);
951 $afiles = $this->GetFilesProperties($src);
952 foreach ($afiles as $afile) {
953 $path = $afile[
"name"];
954 error_log(
"RENAME SEARCH:" . $bsource .
'->' .
$path);
955 if ($path == $bsource) {
956 error_log(
"RENAME FOUND:" . $path .
'-' . $afile[
"path"]);
957 $fspath = $afile[
"path"];
960 $vf->Rename($afile[
"vid"], $bdest);
961 $src->addHistoryEntry(sprintf(_(
"Rename file as %s") , $bdest));
963 $err = $src->modify();
967 $err = $src->modify();
971 $query = sprintf(
"DELETE FROM dav.properties WHERE path = '%s'", pg_escape_string($psource));
973 pg_query($this->db_res,
$query);
975 error_log(
" RENAMETO2 : $bdest : $err");
979 if ($src->doctype ==
'D') {
980 $query = sprintf(
"UPDATE dav.properties SET path = REPLACE(path, '%s', '%s') WHERE path LIKE '%s%%'", pg_escape_string($psource) , pg_escape_string($pdest) , pg_escape_string($psource));
981 pg_query($this->db_res,
$query);
985 if (
$err ==
"")
return "201 Created";
987 error_log(
"DAV MOVE:$err");
988 return "403 Forbidden";
998 error_log(
"---------- >COPY :" . $options[
"path"] .
"->" . $options[
"dest"]);
1000 if (isset($options[
"dest_url"])) {
1001 return "502 bad gateway";
1004 include_once (
"FDL/Class.Doc.php");
1006 $pdirsource = $this->
_unslashify(dirname($options[
"path"]));
1009 $srcid = $this->
path2id($psource);
1011 error_log(
"SRC : $psource " . $srcid);
1015 $destid = $this->
path2id($pdest);
1017 $pdirdest = $this->
_unslashify(dirname($options[
"dest"]));
1018 $dirdestid = $this->
path2id($pdirdest);
1019 $ppdest = new_doc($this->
db_freedom, $dirdestid);
1023 if (
$dest->doctype ==
'D') {
1024 error_log(
"COPY FILE TO REPLACE FOLDER NOT POSSIBLE NORMALLY: $destid:" .
$dest->title);
1025 return "502 bad gateway";
1027 error_log(
"DELETE FILE : $destid:" .
$dest->title);
1033 $query = sprintf(
"DELETE FROM dav.properties WHERE name='fid' and value='%s'", pg_escape_string(
$dest->initid));
1035 pg_query($this->db_res,
$query);
1041 if ($src->doctype ==
"D") {
1043 return "501 not implemented";
1046 $copy = $src->duplicate();
1048 error_log(
"COPY :" . $copy->id);
1049 $afiles = $this->GetFilesProperties($copy);
1050 error_log(
"# FILE :" . count($afiles));
1051 $ff = $copy->GetFirstFileAttributes();
1053 $f = $copy->getRawValue($ff->id);
1054 error_log(
"RENAME SEARCH:" . $f);
1059 $vf->Rename($vid, $bdest);
1060 $copy->addHistoryEntry(sprintf(_(
"Rename file as %s") , $bdest));
1062 $err = $copy->modify();
1065 $err = $ppdest->addFile($copy->id);
1070 error_log(
"MOVE TO PARENT FOLDER : $dirdestid:" .
$err);
1071 if ($bdest != $bsource) {
1072 $copy->setTitle($bdest);
1073 $err = $copy->modify();
1076 error_log(
" RENAMETO : $bdest : $err");
1081 if (
$err ==
"")
return "201 Created";
1083 error_log(
"DAV MOVE:$err");
1084 return "403 Forbidden";
1094 global $prefs, $tab;
1095 error_log(
"---------- >PROPPATCH :" . $options[
"path"]);
1099 $path = $options[
"path"];
1104 foreach ($options[
"props"] as $key => $prop) {
1105 if ($prop[
"ns"] ==
"DAV:") {
1106 $options[
"props"][$key][
'status'] =
"403 Forbidden";
1108 if (isset($prop[
"val"])) {
1110 $query = sprintf(
"delete from dav.properties where path='%s' and name= '%s' and ns='%s'", pg_escape_string($prop[
'path']) , pg_escape_string($prop[
'name']) , pg_escape_string($prop[
'ns']));
1111 pg_query($this->db_res,
$query);
1112 $query = sprintf(
"INSERT INTO dav.properties (path, name, ns, value) values ('%s', '%s', '%s', '%s')", pg_escape_string($prop[
'path']) , pg_escape_string($prop[
'name']) , pg_escape_string($prop[
'ns']) , pg_escape_string($prop[
'val']));
1117 $query = sprintf(
"DELETE FROM dav.properties WHERE path = '%s' AND name = '%s' AND ns = '%s'", pg_escape_string($options[
'path']) , pg_escape_string($prop[
'name']) , pg_escape_string($prop[
'ns']));
1119 pg_query($this->db_res,
$query);
1133 error_log(
"---------- >LOCK :" . $options[
"path"]);
1134 include_once (
"FDL/Class.Doc.php");
1135 if (isset($options[
"update"])) {
1136 $query = sprintf(
"UPDATE dav.locks SET expires = %s where token='%s'", pg_escape_string((time() + 300)) , pg_escape_string($options[
"update"]));
1137 $res = pg_query($this->db_res,
$query);
1139 if (pg_affected_rows($res)) {
1140 $options[
"timeout"] = 300;
1141 error_log(
"LOCK Update succeed");
1144 error_log(print_r($options,
true));
1146 error_log(pg_last_error($this->db_res));
1147 error_log(
"LOCK Update failed");
1154 if (
$doc->isAffected()) {
1155 error_log(
"LOCK " .
$doc->title .
":" . $options[
'locktoken']);
1159 $options[
"timeout"] = time() + 300;
1160 $query = sprintf(
"INSERT INTO dav.locks (token,path,owner,expires,exclusivelock) values ('%s', '%s', '%s', '%s', %s)", pg_escape_string($options[
'locktoken']) , pg_escape_string($options[
'path']) , pg_escape_string($options[
'owner']) , pg_escape_string($options[
'timeout']) , ($options[
'scope'] ===
"exclusive" ?
"1" :
"0"));
1162 $res = pg_query($this->db_res,
$query);
1163 if (pg_affected_rows($res)) {
1167 error_log(
"Cannot lock " .
$doc->title .
":$err");
1172 return "409 Conflict";
1183 error_log(
"---------- >UNLOCK :" . $options[
"path"]);
1184 include_once (
"FDL/Class.Doc.php");
1188 if (
$doc->isAffected()) {
1191 $query = sprintf(
"DELETE FROM dav.locks WHERE path = '%s' AND token = '%s'", pg_escape_string($options[
'path']) , pg_escape_string($options[
'token']));
1192 $res = pg_query($this->db_res,
$query);
1193 if (pg_affected_rows($res)) {
1194 error_log(
" unlock success :" .
$doc->title .
":" . $options[
'token']);
1195 return "204 No Content";
1199 return "204 No Content";
1201 error_log(
"Cannot unlock " .
$doc->title .
":[$err][" . $options[
'token']) .
"]";
1202 return "409 Conflict";
1214 $query = sprintf(
"SELECT owner, token, expires, exclusivelock FROM dav.locks WHERE path = '%s'", pg_escape_string(
$path));
1216 $res = pg_query($this->db_res,
$query);
1219 $row = pg_fetch_array($res);
1220 pg_free_result($res);
1225 "scope" => $row[
"exclusivelock"] ?
"exclusive" :
"shared",
1227 "owner" => $row[
'owner'],
1228 "token" => $row[
'token'],
1229 "expires" => $row[
'expires']
1235 include_once (
"FDL/Class.Doc.php");
1239 if (
$doc->isAffected()) {
1240 if (
$doc->isLocked(
true)) {
1243 "scope" =>
"exclusive",
1245 "owner" =>
$doc->locked,
1246 "token" =>
'opaquelocktoken:' . md5(
$doc->id) ,
1247 "expires" => time() + 3600
1249 error_log(
"LOCK " .
$doc->title);
1276 $query = sprintf(
"INSERT INTO dav.sessions (session, vid, fid, owner, expires) VALUES (%s, %s, %s, %s, %s)", pg_escape_literal(
$sessid) , pg_escape_literal($vid) , pg_escape_literal(
$docid) , pg_escape_literal($owner) , pg_escape_literal($expire));
1278 $res = pg_query($this->db_res,
$query);
1280 $err = pg_last_error($this->db_res);
1281 if (
$err !=
"") error_log(
"$err [$query]");
1283 if (pg_affected_rows($res)) {
1296 $query = sprintf(
"SELECT owner FROM dav.sessions WHERE session = %s AND vid = %s AND fid = %s", pg_escape_literal(
$sessid) , pg_escape_literal($vid) , pg_escape_literal(
$docid));
1298 $res = pg_query($this->db_res,
$query);
1299 $row = pg_fetch_assoc($res);
1300 $owner = $row[
"owner"];
1302 pg_free_result($res);
1316 $query = sprintf(
"SELECT session FROM dav.sessions WHERE owner = %s AND vid = %s AND fid = %s", pg_escape_literal($owner) , pg_escape_literal($vid) , pg_escape_literal(
$docid));
1318 $res = pg_query($this->db_res,
$query);
1319 $row = pg_fetch_assoc($res);
1320 $sid = $row[
"session"];
1322 pg_free_result($res);
1329 $r = strrpos($p,
"/");
1330 return (
$r !==
false) ? substr($p,
$r + 1) : $p;
1335 $fid = intval($fid);
1336 $query = sprintf(
"delete from dav.properties where value='%s' and name= 'fid'", pg_escape_string($fid));
1338 pg_query($this->db_res,
$query);
1350 if (!is_numeric($limit) || $limit < 0) {
1353 $this->folder_max_item = $limit;
1354 return $this->folder_max_item;
1363 if (!is_numeric($this->folder_max_item) || $this->folder_max_item < 0) {
1366 return $this->folder_max_item;
addsession($sessid, $vid, $docid, $owner, $expire=0)
vidpropinfo($path, $docid, $withfile=false)
vault_properties($idfile, $teng_name="")
newFreeVaultFile($dbaccess)
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
getSession($docid, $vid, $owner)
getFilesProperties(&$doc)
PROPFIND(&$options, &$files)
GetDir($fspath, &$options)
__construct($dbaccess="")
check_auth($type, $user, $pass)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
_can_execute($name, $path=false)
if(($docid!==0)&&(!is_numeric($docid))) $query
if($file) if($subject==""&&$file) if($subject=="") $err
getLogin($docid, $vid, $sessid)
readfolder($fspath, $onlyfld=false)
docpropinfo(&$doc, $path, $firstlevel)
path2id($fspath, &$vid=null)