File: webdav.php

package info (click to toggle)
extplorer 2.1.0b6%2Bdfsg.3-4%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,156 kB
  • sloc: php: 14,874; xml: 884; makefile: 124; sh: 35
file content (93 lines) | stat: -rw-r--r-- 2,953 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php

# Author: Vincent JAULIN
# Copyright: Keyphrene.com 2008 @ all rights reserved

# Tests on:
# PHP 5 mode CGI
# PHP5 mode mod_php

# INSTALL
# 1 - Create a folder
# 2 - Extract and Copy package on your site with a client FTP
# 3 - Configure webdav.php (change this script name for security reason)
# 4 - Create .htaccess in your webdav folder (only PHP-CGI)
# <IfModule mod_rewrite.c>
#	RewriteEngine on
#	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
# </IfModule>
# 5 - Test with a Webdav Client (Naja for example ;-))
define('_JEXEC', 1 );

require_once(dirname(__FILE__)."/webdav_authenticate.php");
include_once(dirname(__FILE__)."/config/conf.php");

if( empty($GLOBALS['allow_webdav'] ) || isset( $_REQUEST['allow_webdav'] ) ) {
	header('HTTP/1.0 403 Forbidden');
	die('403 Forbidden');
}

include_once(dirname(__FILE__)."/include/users.php");
include_once(dirname(__FILE__)."/include/functions.php");
define('_EXT_PATH', dirname(__FILE__));

ini_set("default_charset", "UTF-8");
ini_set("display_errors", 0 );

# Activate if your PHP is CGI mode
$phpcgi = substr(PHP_SAPI, 0, 3) == 'cgi';
$realm = 'Restricted Area: eXtplorer WebDAV';

load_users();

foreach( $GLOBALS["users"] as $user ) {
	$users[$user[0]] = $user[1];
}

// Authenticate the user or ask to login. We have to use basic authorization, because the passwords are stored in an encrypted format
AuthenticationBasicHTTP($realm, $users, $phpcgi);

require_once( dirname(__FILE__). "/libraries/HTTP/WebDAV/Server/Filesystem.php");
$server = new HTTP_WebDAV_Server_Filesystem();

if( stristr( $_SERVER['SCRIPT_NAME'], 'administrator/components/com_extplorer')) {
	$jconfig_file = dirname(__FILE__). "/../../../configuration.php";
	$mosConfig_absolute_path = '';
	if( file_exists( $jconfig_file )) {
		include_once($jconfig_file);
	}
	if( class_exists('jconfig')) {
		// Joomla! >= 1.5
		$config = new JConfig;
		$server->db_host = $config->host;
		$server->db_name = $config->db;
		$server->db_user = $config->user;
		$server->db_passwd = $config->password;
		$server->db_type = $config->dbtype;
		$server->db_prefix = $config->dbprefix.'_extwebdav_';
		
	} elseif(!empty($mosConfig_absolute_path)) {
		// Joomla! 1.0
		$server->db_host = $mosConfig_host;
		$server->db_name = $mosConfig_db;
		$server->db_user = $mosConfig_user;
		$server->db_passwd = $mosConfig_password;
		$server->db_type = 'mysql';
		$server->db_prefix = $mosConfig_dbprefix.'_extwebdav_';
	} else {
		header( 'HTTP/1.0 500 Internal Error');
		echo 'Internal Error: Configuration File not found.';
		exit;
	}
} else {
	$server->db_host = $GLOBALS['DB_HOST'];
	$server->db_name = $GLOBALS['DB_NAME'];
	$server->db_user = $GLOBALS['DB_USER'];
	$server->db_passwd = $GLOBALS['DB_PASSWORD'];
	$server->db_type = $GLOBALS['DB_TYPE'];
}

# Real path of your site
$server->ServeRequest($GLOBALS["home_dir"]);

?>