This repository was archived by the owner on Nov 19, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaldav.php
More file actions
executable file
·150 lines (116 loc) · 4.73 KB
/
Copy pathcaldav.php
File metadata and controls
executable file
·150 lines (116 loc) · 4.73 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
ini_set("display_errors", 1);
ini_set("track_errors", 1);
ini_set("html_errors", 1);
error_reporting(E_ALL);
// *******************************
// Checking PHP version
// *******************************
if (version_compare(phpversion(), '5.2', '<')) die ('TYPO3 requires PHP 5.2.0 or higher.');
// *******************************
// Set error reporting
// *******************************
if (defined('E_DEPRECATED')) {
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
} else {
error_reporting(E_ALL ^ E_NOTICE);
}
$TYPO3_MISC['microtime_start'] = microtime(true);
define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
define('TYPO3_MODE','FE');
$PATH_thisScript = str_replace('//', '/', str_replace('\\', '/',dirname($_SERVER['SCRIPT_FILENAME'])));
if (!defined('PATH_site')) define('PATH_site', str_replace('typo3conf/ext/caldav','',$PATH_thisScript));
if (!defined('PATH_t3lib')) define('PATH_t3lib', PATH_site.'t3lib/');
define('TYPO3_mainDir', 'typo3/'); // This is the directory of the backend administration for the sites of this TYPO3 installation.
define('PATH_typo3', PATH_site.TYPO3_mainDir);
define('PATH_typo3conf', PATH_site.'typo3conf/');
if (!defined('PATH_tslib')) {
if (@is_dir(PATH_site.TYPO3_mainDir.'sysext/cms/tslib/')) {
define('PATH_tslib', PATH_site.TYPO3_mainDir.'sysext/cms/tslib/');
} elseif (@is_dir(PATH_site.'tslib/')) {
define('PATH_tslib', PATH_site.'tslib/');
}
}
$TYPO3_AJAX = false;
define('PATH_thisScript',str_replace('//', '/', str_replace('\\', '/',dirname($_SERVER['SCRIPT_FILENAME']))).'/caldav.php');
if (!@is_dir(PATH_typo3conf)) die('Cannot find configuration. This file is probably executed from the wrong location.');
// *********************
// Unset variable(s) in global scope (fixes #13959)
// *********************
unset($error);
// *********************
// Prevent any output until AJAX/compression is initialized to stop
// AJAX/compression data corruption
// *********************
ob_start();
require __DIR__ . '/../../../typo3/sysext/core/Classes/Core/Bootstrap.php';
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
->baseSetup('')
->redirectToInstallerIfEssentialConfigurationDoesNotExist();
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
->startOutputBuffering()
->loadConfigurationAndInitialize()
->loadTypo3LoadedExtAndExtLocalconf(TRUE)
->applyAdditionalConfigurationSettings();
// Timetracking started
$configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
if (empty($configuredCookieName)) {
$configuredCookieName = 'be_typo_user';
}
if ($_COOKIE[$configuredCookieName]) {
$TT = new \TYPO3\CMS\Core\TimeTracker\TimeTracker();
} else {
$TT = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker();
}
$TT->start();
$TT->push('','Script start');
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeTypo3DbGlobal();
/** @var $TSFE \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
$TSFE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
$TYPO3_CONF_VARS,
\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'),
\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type'),
\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('no_cache'),
\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cHash'),
\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('jumpurl'),
\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('MP'),
\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RDCT')
);
$TSFE->connectToDB();
$TSFE->sendRedirect();
$TT->pull();
/*
CalendarServer example
This server features CalDAV and ACL support
*/
// settings
// If you want to run the SabreDAV server in a custom location (using mod_rewrite for instance)
// You can override the baseUri here.
// $baseUri = '/';
if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port'])) {
$typo_db_host = TYPO3_db_host.';port='.$GLOBALS['TYPO3_CONF_VARS']['DB']['port'];
} else {
$typo_db_host = str_replace(':',';port=',TYPO3_db_host);
}
/* Database */
//$pdo = new PDO('sqlite:data/db.sqlite');
$pdo = new PDO('mysql:host='.$typo_db_host.';dbname='.TYPO3_db,TYPO3_db_username,TYPO3_db_password);
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
//Mapping PHP errors to exceptions
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
//set_error_handler("exception_error_handler");
// Files we need
require_once PATH_typo3conf.'/ext/caldav/lib/Sabre/autoload.php';
// The object tree needs in turn to be passed to the server class
$server = new Sabre_CalDAV_TYPO3Server($pdo);
if (isset($baseUri)) {
$server->setBaseUri($baseUri);
}
// Support for html frontend
$browser = new Sabre_DAV_Browser_Plugin();
$server->addPlugin($browser);
// And off we go!
$server->exec();