EGroupware /
egroupware
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * FileManger - WebDAV access for ownCloud clients |
||
| 4 | * |
||
| 5 | * ownCloud clients sync by default local ownCloud dir to /clientsync on server. |
||
| 6 | * |
||
| 7 | * EGroupware now temporary mounts vfs://default/home/$user on /clientsync, |
||
| 8 | * so ownCloud clients syncs with users home-dir, unless admin mounts an other directory. |
||
| 9 | * |
||
| 10 | * @link http://owncloud.org/sync-clients/ |
||
| 11 | * @link http://www.egroupware.org |
||
| 12 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
||
| 13 | * @package api |
||
| 14 | * @subpackage vfs |
||
| 15 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
||
| 16 | * @copyright (c) 2006-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
||
| 17 | * @version $Id$ |
||
| 18 | */ |
||
| 19 | |||
| 20 | $starttime = microtime(true); |
||
| 21 | |||
| 22 | /** |
||
| 23 | * check if the given user has access |
||
| 24 | * |
||
| 25 | * Create a session or if the user has no account return authenticate header and 401 Unauthorized |
||
| 26 | * |
||
| 27 | * @param array &$account |
||
| 28 | * @return int session-id |
||
| 29 | */ |
||
| 30 | View Code Duplication | function check_access(&$account) |
|
|
0 ignored issues
–
show
|
|||
| 31 | { |
||
| 32 | if (isset($_GET['auth'])) |
||
| 33 | { |
||
| 34 | list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2); |
||
| 35 | } |
||
| 36 | return egw_digest_auth::autocreate_session_callback($account); |
||
| 37 | } |
||
| 38 | |||
| 39 | $GLOBALS['egw_info'] = array( |
||
| 40 | 'flags' => array( |
||
| 41 | 'disable_Template_class' => True, |
||
| 42 | 'noheader' => True, |
||
| 43 | 'currentapp' => preg_match('|/remote.php/webdav/apps/([A-Za-z0-9_-]+)/|', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager', |
||
| 44 | 'autocreate_session_callback' => 'check_access', |
||
| 45 | 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
||
| 46 | 'auth_realm' => 'EGroupware WebDAV server', // cant use vfs_webdav_server::REALM as autoloading and include path not yet setup! |
||
| 47 | ) |
||
| 48 | ); |
||
| 49 | require_once(__DIR__.'/phpgwapi/inc/class.egw_digest_auth.inc.php'); |
||
| 50 | |||
| 51 | // if you move this file somewhere else, you need to adapt the path to the header! |
||
| 52 | try |
||
| 53 | { |
||
| 54 | include(__DIR__.'/header.inc.php'); |
||
| 55 | } |
||
| 56 | catch (egw_exception_no_permission_app $e) |
||
| 57 | { |
||
| 58 | View Code Duplication | if (isset($GLOBALS['egw_info']['user']['apps']['filemanager'])) |
|
| 59 | { |
||
| 60 | $GLOBALS['egw_info']['currentapp'] = 'filemanager'; |
||
| 61 | } |
||
| 62 | elseif (isset($GLOBALS['egw_info']['user']['apps']['sitemgr-link'])) |
||
| 63 | { |
||
| 64 | $GLOBALS['egw_info']['currentapp'] = 'sitemgr-link'; |
||
| 65 | } |
||
| 66 | else |
||
| 67 | { |
||
| 68 | throw $e; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | //$headertime = microtime(true); |
||
| 72 | |||
| 73 | // temporary mount ownCloud default /clientsync as /home/$user, if not explicitly mounted |
||
| 74 | // so ownCloud dir contains users home-dir by default |
||
| 75 | View Code Duplication | if (strpos($_SERVER['REQUEST_URI'],'/remote.php/webdav/clientsync') !== false && |
|
| 76 | ($fstab=egw_vfs::mount()) && !isset($fstab['/clientsync'])) |
||
| 77 | { |
||
| 78 | $is_root_backup = egw_vfs::$is_root; |
||
| 79 | egw_vfs::$is_root = true; |
||
| 80 | $ok = egw_vfs::mount($url='vfs://default/home/$user', $clientsync='/clientsync', null, false); |
||
| 81 | egw_vfs::$is_root = $is_root_backup; |
||
| 82 | //error_log("mounting ownCloud default '$clientsync' as '$url' ".($ok ? 'successful' : 'failed!')); |
||
| 83 | } |
||
| 84 | |||
| 85 | // webdav is stateless: we dont need to keep the session open, it only blocks other calls to same basic-auth session |
||
| 86 | $GLOBALS['egw']->session->commit_session(); |
||
| 87 | |||
| 88 | $webdav_server = new vfs_webdav_server(); |
||
| 89 | $webdav_server->ServeRequest('/webdav'); |
||
| 90 | //error_log(sprintf('WebDAV %s request: status "%s", took %5.3f s'.($headertime?' (header include took %5.3f s)':''),$_SERVER['REQUEST_METHOD'].' '.$_SERVER['PATH_INFO'],$webdav_server->_http_status,microtime(true)-$starttime,$headertime-$starttime)); |
||
| 91 |
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignoreannotation.See also the PhpDoc documentation for @ignore.