moved webdav handler in the root dir, as its now a general service and not only used by filemanager

This commit is contained in:
Ralf Becker 2008-05-10 21:15:46 +00:00
parent fd5b231760
commit 5cfc38b4f6
3 changed files with 64 additions and 46 deletions

View File

@ -1,54 +1,15 @@
<?php <?php
/** /**
* FileManger - WebDAV access * eGroupWare - WebDAV access
* *
* Using the PEAR HTTP/WebDAV/Server class (which need to be installed!) * Just for backward compatibility of the url: better use the webdav.php in the root.
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package filemanger * @package filemanager
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2008 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$ * @version $Id$
*/ */
/** include('../webdav.php');
* check if the given user has access
*
* Create a session or if the user has no account return authenticate header and 401 Unauthorized
*
* @param array &$account
* @return int session-id
*/
function check_access(&$account)
{
$account = array(
'login' => $_SERVER['PHP_AUTH_USER'],
'passwd' => $_SERVER['PHP_AUTH_PW'],
'passwd_type' => 'text',
);
if (!($sessionid = $GLOBALS['egw']->session->create($account)))
{
header('WWW-Authenticate: Basic realm="eGroupWare WebDAV"');
header("HTTP/1.1 401 Unauthorized");
header("X-WebDAV-Status: 401 Unauthorized", true);
exit;
}
return $sessionid;
}
// if we are called with a /apps/$app path, use that $app as currentapp, to not require filemanager rights for the links
$parts = explode('/',$_SERVER['PATH_INFO']);
$app = count($parts) > 3 && $parts[1] == 'apps' ? $parts[2] : 'filemanager';
$GLOBALS['egw_info']['flags'] = array(
'disable_Template_class' => True,
'noheader' => True,
'currentapp' => $app,
'autocreate_session_callback' => 'check_access',
);
// if you move this file somewhere else, you need to adapt the path to the header!
include('../header.inc.php');
$webdav_server = new vfs_webdav_server();
$webdav_server->ServeRequest();

View File

@ -954,7 +954,7 @@ class egw_vfs extends vfs_stream_wrapper
{ {
$path = parse_url($path,PHP_URL_PATH); $path = parse_url($path,PHP_URL_PATH);
} }
return '/filemanager/webdav.php'.$path; return '/webdav.php'.$path;
} }
/** /**

57
webdav.php Normal file
View File

@ -0,0 +1,57 @@
<?php
/**
* FileManger - WebDAV access
*
* Using the PEAR HTTP/WebDAV/Server class (which need to be installed!)
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @subpackage vfs
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/
/**
* check if the given user has access
*
* Create a session or if the user has no account return authenticate header and 401 Unauthorized
*
* @param array &$account
* @return int session-id
*/
function check_access(&$account)
{
$account = array(
'login' => $_SERVER['PHP_AUTH_USER'],
'passwd' => $_SERVER['PHP_AUTH_PW'],
'passwd_type' => 'text',
);
if (!($sessionid = $GLOBALS['egw']->session->create($account)))
{
header('WWW-Authenticate: Basic realm="'.vfs_webdav_server::REALM.'"');
header("HTTP/1.1 401 Unauthorized");
header("X-WebDAV-Status: 401 Unauthorized", true);
exit;
}
return $sessionid;
}
// if we are called with a /apps/$app path, use that $app as currentapp, to not require filemanager rights for the links
$parts = explode('/',$_SERVER['PATH_INFO']);
$app = count($parts) > 3 && $parts[1] == 'apps' ? $parts[2] : 'filemanager';
$GLOBALS['egw_info'] = array(
'flags' => array(
'disable_Template_class' => True,
'noheader' => True,
'currentapp' => $app,
'autocreate_session_callback' => 'check_access',
)
);
// if you move this file somewhere else, you need to adapt the path to the header!
include(dirname(__FILE__).'/header.inc.php');
$webdav_server = new vfs_webdav_server();
$webdav_server->ServeRequest();