-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of existing SambaDAV package
Adapt the 'webfolders' internal project into a standalone project called SambaDAV, to be open-sourced and hosted on GitHub.
- Loading branch information
Alfred Klomp
committed
Jul 25, 2013
0 parents
commit f534739
Showing
32 changed files
with
3,916 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Ignore this file for export: | ||
.gitattributes export-ignore | ||
|
||
# These .gitignore files ensure the (otherwise empty) directory stays in | ||
# the repo, but these placeholder files shouldn't be exported themselves: | ||
src/data/.gitignore export-ignore | ||
src/lib/.gitignore export-ignore | ||
src/log/.gitignore export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Wed Jul 24 2013 Alfred Klomp <[email protected]> 0.1 | ||
- Adapt the `webfolders` internal project into a standalone project called | ||
SambaDAV, to be open-sourced and hosted on GitHub. |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# $Id: Makefile,v 1.1 2013/01/07 10:00:01 alfred Exp $ | ||
|
||
all: file.png dir.png | ||
|
||
%.png: ../%.svg | ||
inkscape \ | ||
--export-png=$@ \ | ||
--export-dpi=90 \ | ||
$^ | ||
advpng -z4 $@ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
diff -ruN ../sabre-dav-1.8.6-orig/lib/Sabre/DAV/Browser/Plugin.php ./lib/Sabre/DAV/Browser/Plugin.php | ||
--- ../sabre-dav-1.8.6-orig/lib/Sabre/DAV/Browser/Plugin.php 2013-06-18 01:12:05.000000000 +0200 | ||
+++ ./lib/Sabre/DAV/Browser/Plugin.php 2013-07-15 14:34:22.000000000 +0200 | ||
@@ -223,25 +223,32 @@ | ||
$version = DAV\Version::VERSION ."-". DAV\Version::STABILITY; | ||
} | ||
|
||
- $html = "<html> | ||
-<head> | ||
- <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . $version . "</title> | ||
- <style type=\"text/css\"> | ||
- body { Font-family: arial} | ||
- h1 { font-size: 150% } | ||
- </style> | ||
- "; | ||
+ $html = "<!DOCTYPE html> | ||
+<html> | ||
+ <head> | ||
+ <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . $version . "</title> | ||
+ <link rel=\"stylesheet\" href=\"/webfolders/style.css\"/>"; | ||
|
||
if ($this->enableAssets) { | ||
$html.='<link rel="shortcut icon" href="'.$this->getAssetUrl('favicon.ico').'" type="image/vnd.microsoft.icon" />'; | ||
} | ||
|
||
- $html .= "</head> | ||
-<body> | ||
- <h1>Index for " . $this->escapeHTML($path) . "/</h1> | ||
- <table> | ||
- <tr><th width=\"24\"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr> | ||
- <tr><td colspan=\"5\"><hr /></td></tr>"; | ||
+ $html .= " </head> | ||
+ <body> | ||
+ <p id=\"logout\"><a href=\"?logout\">switch user (logout)</a></p> | ||
+ <h1>Index for " . $this->escapeHTML($path) . "/</h1> | ||
+ <table> | ||
+ <colgroup> | ||
+ <col style=\"width:15px\"/> | ||
+ <col/> | ||
+ <col/> | ||
+ <col/> | ||
+ <col/> | ||
+ </colgroup> | ||
+ <thead> | ||
+ <tr><th></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr> | ||
+ </thead> | ||
+ <tbody>"; | ||
|
||
$files = $this->server->getPropertiesForPath($path,array( | ||
'{DAV:}displayname', | ||
@@ -259,8 +266,8 @@ | ||
list($parentUri) = DAV\URLUtil::splitPath($path); | ||
$fullPath = DAV\URLUtil::encodePath($this->server->getBaseUri() . $parentUri); | ||
|
||
- $icon = $this->enableAssets?'<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="Parent" /></a>':''; | ||
- $html.= "<tr> | ||
+ $icon = $this->enableAssets?'<a href="' . $fullPath . '"><img src="/webfolders/dir.png" alt="Parent" /></a>':''; | ||
+ $html.= "<tr class=\"dir\"> | ||
<td>$icon</td> | ||
<td><a href=\"{$fullPath}\">..</a></td> | ||
<td>[parent]</td> | ||
@@ -291,7 +298,7 @@ | ||
// Some name mapping is preferred | ||
switch($v) { | ||
case '{DAV:}collection' : | ||
- $type[$k] = 'Collection'; | ||
+ $type[$k] = 'Directory'; | ||
break; | ||
case '{DAV:}principal' : | ||
$type[$k] = 'Principal'; | ||
@@ -328,7 +335,7 @@ | ||
if (!$type) $type = 'Unknown'; | ||
|
||
$size = isset($file[200]['{DAV:}getcontentlength'])?(int)$file[200]['{DAV:}getcontentlength']:''; | ||
- $lastmodified = isset($file[200]['{DAV:}getlastmodified'])?$file[200]['{DAV:}getlastmodified']->getTime()->format(\DateTime::ATOM):''; | ||
+ $lastmodified = isset($file[200]['{DAV:}getlastmodified'])?$file[200]['{DAV:}getlastmodified']->getTime()->format(\DateTime::RFC2822):''; | ||
|
||
$fullPath = DAV\URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path?$path . '/':'') . $name,'/')); | ||
|
||
@@ -344,7 +351,7 @@ | ||
foreach(array_reverse($this->iconMap) as $class=>$iconName) { | ||
|
||
if ($node instanceof $class) { | ||
- $icon = '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl($iconName . $this->iconExtension) . '" alt="" width="24" /></a>'; | ||
+ $icon = '<a href="' . $fullPath . '"><img src="/webfolders/' . (($iconName == 'icons/collection') ? 'dir.png' : 'file.png') . '" alt="" /></a>'; | ||
break; | ||
} | ||
|
||
@@ -353,7 +360,9 @@ | ||
|
||
} | ||
|
||
- $html.= "<tr> | ||
+ $trclass = ($type == 'Directory') ? 'class="dir"' : 'class="file"'; | ||
+ | ||
+ $html.= "<tr $trclass> | ||
<td>$icon</td> | ||
<td><a href=\"{$fullPath}\">{$displayName}</a></td> | ||
<td>{$type}</td> | ||
@@ -362,8 +371,11 @@ | ||
</tr>"; | ||
|
||
} | ||
- | ||
- $html.= "<tr><td colspan=\"5\"><hr /></td></tr>"; | ||
+ $html .= " | ||
+ </tbody> | ||
+ </table> | ||
+ <table id=\"actions\"> | ||
+ <tbody>"; | ||
|
||
$output = ''; | ||
|
||
@@ -373,10 +385,12 @@ | ||
|
||
$html.=$output; | ||
|
||
- $html.= "</table> | ||
- <address>Generated by SabreDAV " . $version . " (c)2007-2013 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address> | ||
- </body> | ||
- </html>"; | ||
+ $html.= " | ||
+ </tbody> | ||
+ </table> | ||
+ <address>Generated by SabreDAV " . $version . " (c)2007-2013 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address> | ||
+ </body> | ||
+</html>"; | ||
|
||
return $html; | ||
|
||
@@ -403,13 +417,13 @@ | ||
if (get_class($node)==='Sabre\\DAV\\SimpleCollection') | ||
return; | ||
|
||
- $output.= '<tr><td colspan="2"><form method="post" action=""> | ||
+ $output.= '<tr><td><form method="post"> | ||
<h3>Create new folder</h3> | ||
<input type="hidden" name="sabreAction" value="mkcol" /> | ||
Name: <input type="text" name="name" /><br /> | ||
<input type="submit" value="create" /> | ||
</form> | ||
- <form method="post" action="" enctype="multipart/form-data"> | ||
+ <form method="post" enctype="multipart/form-data"> | ||
<h3>Upload file</h3> | ||
<input type="hidden" name="sabreAction" value="put" /> | ||
Name (optional): <input type="text" name="name" /><br /> | ||
@@ -429,7 +443,7 @@ | ||
*/ | ||
protected function getAssetUrl($assetName) { | ||
|
||
- return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName); | ||
+ return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
diff -ruN ../SabreDAV-orig//lib/Sabre/DAV/Browser/Plugin.php ./lib/Sabre/DAV/Browser/Plugin.php | ||
--- ../SabreDAV-orig//lib/Sabre/DAV/Browser/Plugin.php 2013-01-07 12:12:47.000000000 +0100 | ||
+++ ./lib/Sabre/DAV/Browser/Plugin.php 2013-01-07 12:16:54.000000000 +0100 | ||
@@ -277,6 +277,9 @@ | ||
|
||
} | ||
|
||
+ // Sort files by href (filename): | ||
+ uasort($files, 'self::compare_filenames'); | ||
+ | ||
foreach($files as $file) { | ||
|
||
// This is the current directory, we can skip it | ||
@@ -502,4 +505,27 @@ | ||
|
||
} | ||
|
||
+ /* Helper function for uasort; sort file list: directories before files, else alphabetically */ | ||
+ private function compare_filenames ($a, $b) | ||
+ { | ||
+ $isdir_a = $isdir_b = FALSE; | ||
+ if (isset($a[200]['{DAV:}resourcetype'])) { | ||
+ $isdir_a = $a[200]['{DAV:}resourcetype']->getValue(); | ||
+ $isdir_a = (isset($isdir_a[0]) && $isdir_a[0] == '{DAV:}collection'); | ||
+ } | ||
+ if (isset($b[200]['{DAV:}resourcetype'])) { | ||
+ $isdir_b = $b[200]['{DAV:}resourcetype']->getValue(); | ||
+ $isdir_b = (isset($isdir_b[0]) && $isdir_b[0] == '{DAV:}collection'); | ||
+ } | ||
+ /* Unequal types? Directories always win: */ | ||
+ if ($isdir_a && !$isdir_b) return -1; | ||
+ if ($isdir_b && !$isdir_a) return 1; | ||
+ | ||
+ /* Equal types? Sort alphabetically: */ | ||
+ if (!isset($a['href']) || !isset($b['href']) || $a['href'] == $b['href']) { | ||
+ return 0; | ||
+ } | ||
+ return strcasecmp($a['href'], $b['href']); | ||
+ } | ||
+ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
diff -ruN ../sabre-dav-1.8.6-orig/lib/Sabre/DAV/Browser/Plugin.php ./lib/Sabre/DAV/Browser/Plugin.php | ||
--- ../sabre-dav-1.8.6-orig/lib/Sabre/DAV/Browser/Plugin.php 2013-07-15 14:38:29.000000000 +0200 | ||
+++ ./lib/Sabre/DAV/Browser/Plugin.php 2013-07-15 14:39:19.000000000 +0200 | ||
@@ -232,11 +232,26 @@ | ||
if ($this->enableAssets) { | ||
$html.='<link rel="shortcut icon" href="'.$this->getAssetUrl('favicon.ico').'" type="image/vnd.microsoft.icon" />'; | ||
} | ||
+ $parent = $this->server->tree->getNodeForPath($path); | ||
|
||
$html .= " </head> | ||
<body> | ||
<p id=\"logout\"><a href=\"?logout\">switch user (logout)</a></p> | ||
<h1>Index for " . $this->escapeHTML($path) . "/</h1> | ||
+ <table id=\"actions\"> | ||
+ <tbody>"; | ||
+ | ||
+ $output = ''; | ||
+ | ||
+ if ($this->enablePost) { | ||
+ $this->server->broadcastEvent('onHTMLActionsPanel',array($parent, &$output)); | ||
+ } | ||
+ | ||
+ $html.=$output; | ||
+ | ||
+ $html.= " | ||
+ </tbody> | ||
+ </table> | ||
<table> | ||
<colgroup> | ||
<col style=\"width:15px\"/> | ||
@@ -258,8 +273,6 @@ | ||
'{DAV:}getlastmodified', | ||
),1); | ||
|
||
- $parent = $this->server->tree->getNodeForPath($path); | ||
- | ||
|
||
if ($path) { | ||
|
||
@@ -377,21 +390,7 @@ | ||
$html .= " | ||
</tbody> | ||
</table> | ||
- <table id=\"actions\"> | ||
- <tbody>"; | ||
- | ||
- $output = ''; | ||
- | ||
- if ($this->enablePost) { | ||
- $this->server->broadcastEvent('onHTMLActionsPanel',array($parent, &$output)); | ||
- } | ||
- | ||
- $html.=$output; | ||
- | ||
- $html.= " | ||
- </tbody> | ||
- </table> | ||
- <address>Generated by SabreDAV " . $version . " (c)2007-2013 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address> | ||
+ <address>Generated by SabreDAV " . $version . " (c)2007-2013 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address> | ||
</body> | ||
</html>"; | ||
|
||
@@ -420,20 +419,22 @@ | ||
if (get_class($node)==='Sabre\\DAV\\SimpleCollection') | ||
return; | ||
|
||
- $output.= '<tr><td><form method="post"> | ||
- <h3>Create new folder</h3> | ||
- <input type="hidden" name="sabreAction" value="mkcol" /> | ||
- Name: <input type="text" name="name" /><br /> | ||
- <input type="submit" value="create" /> | ||
- </form> | ||
- <form method="post" enctype="multipart/form-data"> | ||
- <h3>Upload file</h3> | ||
- <input type="hidden" name="sabreAction" value="put" /> | ||
- Name (optional): <input type="text" name="name" /><br /> | ||
- File: <input type="file" name="file" /><br /> | ||
- <input type="submit" value="upload" /> | ||
- </form> | ||
- </td></tr>'; | ||
+ $output .= ' | ||
+<tr><form method="post"><input name="sabreAction" value="mkcol" type="hidden"> | ||
+ <td><h3>New folder</h3></td> | ||
+ <td><label for="name">Name:</label></td> | ||
+ <td colspan="3"><input name="name" type="text"></td> | ||
+ <td><input value="create" type="submit"></td> | ||
+ </form> | ||
+</tr> | ||
+<tr><form method="post" enctype="multipart/form-data"><input name="sabreAction" value="put" type="hidden"> | ||
+ <td><h3>Upload file</h3></td> | ||
+ <td><label for="file">File:</label></td> | ||
+ <td><input name="file" type="file"></td> | ||
+ <td><label for="name">Name (optional):</label></td> | ||
+ <td><input name="name" type="text"></td> | ||
+ <td><input value="upload" type="submit"></td> | ||
+</form></tr>'; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php // $Id: config.inc.php,v 1.7 2013/07/23 16:04:33 alfred Exp $ | ||
/* | ||
* Copyright (C) 2013 Bokxing IT, http://www.bokxing-it.nl | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Project page: <https://github.com/bokxing-it/sambadav/> | ||
* | ||
*/ | ||
|
||
// Base directory on webserver (the root URL): | ||
define('SERVER_BASEDIR', '/webfolders/'); | ||
|
||
// Full path to the smbclient utility: | ||
define('SMBCLIENT_PATH', '/usr/bin/smbclient'); | ||
|
||
// Allow anonymous logins/browsing (no username/pass): | ||
define('ANONYMOUS_ALLOW', FALSE); | ||
|
||
// Allow *only* anonymous logins: this disables the password prompt; implies ANONYMOUS_ALLOW: | ||
define('ANONYMOUS_ONLY', FALSE); | ||
|
||
// Don't procure eTags for files larger than this size (bytes): | ||
// NB: calculating the eTag is very resource-intensive, because the file must | ||
// be streamed through smbclient and md5summed. The (limited) utility of eTags | ||
// doesn't really justify the significant processing overhead. | ||
define('ETAG_SIZE_LIMIT', -1); | ||
|
||
// Set to TRUE to use disk cache in /dev/shm/webfolders, FALSE to disable: | ||
define('CACHE_USE', TRUE); | ||
|
||
// Dir to use for cache files; preferably keep this in /dev/shm for speed; | ||
// the lowest-level directory is created if not exists: | ||
define('CACHE_DIR', '/dev/shm/webfolders'); | ||
|
||
// Use LDAP authentication on top of smbclient authentication? | ||
define('LDAP_AUTH', FALSE); | ||
|
||
// Array of LDAP group(s) that the user must be a member of, FALSE for bind-only check: | ||
$ldap_groups = FALSE; |
Oops, something went wrong.