2 commits - doc/kolab-freebusy.conf doc/kolab-freebusy.logrotate public_html/.htaccess public_html/index.php web/.htaccess web/index.php
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Tue Nov 26 10:01:19 CET 2013
doc/kolab-freebusy.conf | 13 ++++
doc/kolab-freebusy.logrotate | 6 +
public_html/.htaccess | 7 ++
public_html/index.php | 137 +++++++++++++++++++++++++++++++++++++++++++
web/.htaccess | 7 --
web/index.php | 137 -------------------------------------------
6 files changed, 163 insertions(+), 144 deletions(-)
New commits:
commit 6d53e8f0aebb479cbae2e3db7f7c7b471d5db93e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Tue Nov 26 10:01:03 2013 +0100
Add a sample apache configuration file and logrotate sample
diff --git a/doc/kolab-freebusy.conf b/doc/kolab-freebusy.conf
new file mode 100644
index 0000000..fa73d85
--- /dev/null
+++ b/doc/kolab-freebusy.conf
@@ -0,0 +1,13 @@
+ScriptAlias /freebusy /usr/share/kolab-freebusy/public_html/index.php
+
+<Directory "/usr/share/kolab-freebusy/public_html/">
+ AllowOverride All
+
+ <ifModule mod_authz_core.c>
+ Require all granted
+ </ifModule>
+ <ifModule !mod_authz_core.c>
+ Order Allow,Deny
+ Allow from All
+ </ifModule>
+</Directory>
diff --git a/doc/kolab-freebusy.logrotate b/doc/kolab-freebusy.logrotate
new file mode 100644
index 0000000..8b6d375
--- /dev/null
+++ b/doc/kolab-freebusy.logrotate
@@ -0,0 +1,6 @@
+/var/log/kolab-freebusy/freebusy.log {
+ create 0640 apache apache
+ compress
+ missingok
+ notifempty
+}
commit bd44a73daf13c6ba6493bbcc4681d699b64c7527
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Tue Nov 26 10:00:49 2013 +0100
Use traditional public_html
diff --git a/public_html/.htaccess b/public_html/.htaccess
new file mode 100644
index 0000000..2b669c8
--- /dev/null
+++ b/public_html/.htaccess
@@ -0,0 +1,7 @@
+RewriteEngine On
+
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule (.*) index.php [qsappend,last]
+
+
diff --git a/public_html/index.php b/public_html/index.php
new file mode 100644
index 0000000..fcbce69
--- /dev/null
+++ b/public_html/index.php
@@ -0,0 +1,137 @@
+<?php
+
+/**
+ * Kolab Server Free/Busy Service Endpoint
+ *
+ * This is the public API to provide Free/Busy information for Kolab users.
+ *
+ * @version 0.1.2
+ * @author Thomas Bruederli <bruederli at kolabsys.com>
+ *
+ * Copyright (C) 2013, Kolab Systems AG <contact at kolabsys.com>
+ *
+ * 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/>.
+ */
+
+
+define('KOLAB_FREEBUSY_ROOT', realpath('../'));
+
+// suppress error notices
+ini_set('error_reporting', E_ALL &~ E_NOTICE);
+
+// use composer's autoloader for both dependencies and local lib
+require_once KOLAB_FREEBUSY_ROOT . '/vendor/autoload.php';
+
+use Kolab\Config;
+use Kolab\FreeBusy\Utils;
+use Kolab\FreeBusy\Logger;
+use Kolab\FreeBusy\Directory;
+use Kolab\FreeBusy\HTTPAuth;
+
+
+// load config
+$config = Config::get_instance(KOLAB_FREEBUSY_ROOT . '/config');
+if ($config->valid()) {
+ // check for trusted IP first
+ $remote_ip = Utils::remoteIP();
+ $trusted_ip = $config->trustednetworks ? Utils::checkIPRange($remote_ip, $config->get('trustednetworks.allow', array(), Config::ARR)) : false;
+
+ $log = Logger::get('web');
+
+ $uri = $_SERVER['REDIRECT_URL'];
+
+ // we're not always redirected here
+ if (empty($uri)) {
+ $uri = $_SERVER['REQUEST_URI'];
+ $log->addDebug('Request (direct): ' . $uri, array('ip' => $remote_ip, 'trusted' => $trusted_ip));
+ } else {
+ $log->addDebug('Request (redirect): ' . $uri, array('ip' => $remote_ip, 'trusted' => $trusted_ip));
+ }
+
+ // check HTTP authentication
+ if (!$trusted_ip && $config->httpauth) {
+ if (!HTTPAuth::check($config->httpauth)) {
+ $log->addDebug("Abort with 401 Unauthorized");
+ header('WWW-Authenticate: Basic realm="Kolab Free/Busy Service"');
+ header($_SERVER['SERVER_PROTOCOL'] . " 401 Unauthorized", true);
+ exit;
+ }
+ }
+
+ #header('Content-type: text/calendar; charset=utf-8', true);
+ header('Content-type: text/plain; charset=utf-8', true);
+
+ // analyse request
+ $url = array_filter(explode('/', $uri));
+ $user = strtolower(array_pop($url));
+ $action = strtolower(array_pop($url));
+ $extended = false;
+
+ // remove file extension
+ if (preg_match('/^(.+)\.([ipx]fb)$/i', $user, $m)) {
+ $user = $m[1];
+ $extended = $m[2] == 'xfb';
+ }
+
+ // iterate over directories
+ foreach ($config->directory as $key => $dirconfig) {
+ $log->addDebug("Trying directory $key", $dirconfig);
+
+ $directory = Directory::factory($dirconfig);
+ if ($directory && ($fbdata = $directory->getFreeBusyData($user, $extended))) {
+ $log->addInfo("Found valid data for user $user in directory $key");
+ echo $fbdata;
+ exit;
+ }
+ }
+
+ // return 404 if request was sent from a trusted IP
+ if ($trusted_ip) {
+ $log->addDebug("Returning '404 Not Found' for user $user");
+ header($_SERVER['SERVER_PROTOCOL'] . " 404 Not found", true);
+ }
+ else {
+ $log->addInfo("Returning empty Free/Busy list for user $user");
+
+ $now = time();
+ $dtformat = 'Ymd\THis\Z';
+
+ // NOTE: The following settings should probably correspond with
+ // whatever period of time kolab-freebusyd thinks it should use.
+
+ // Should probably be a setting. For now, do 8 weeks in the past
+ $start = $now - (60 * 60 * 24 * 7 * 8);
+ // Should probably be a setting. For now, do 16 weeks into the future
+ $end = $now + (60 * 60 * 24 * 7 * 16);
+
+ // Return an apparent empty Free/Busy list.
+ print "BEGIN:VCALENDAR\n";
+ print "VERSION:2.0\n";
+ print "PRODID:-//kolab.org//NONSGML Kolab Server 3//EN\n";
+ print "METHOD:PUBLISH\n";
+ print "BEGIN:VFREEBUSY\n";
+ print "ORGANIZER:MAILTO:" . $user . ".ifb\n";
+ print "DTSTAMP:" . gmdate($dtformat) . "\n";
+ print "DTSTART:" . gmdate($dtformat, $start) . "\n";
+ print "DTEND:" . gmdate($dtformat, $end) . "\n";
+ print "COMMENT:This is a dummy vfreebusy that indicates an empty calendar\n";
+ print "FREEBUSY:19700101T000000Z/19700101T000000Z\n";
+ print "END:VFREEBUSY\n";
+ print "END:VCALENDAR\n";
+ }
+}
+
+// exit with error
+# header($_SERVER['SERVER_PROTOCOL'] . " 500 Internal Server Error", true);
+
diff --git a/web/.htaccess b/web/.htaccess
deleted file mode 100644
index 2b669c8..0000000
--- a/web/.htaccess
+++ /dev/null
@@ -1,7 +0,0 @@
-RewriteEngine On
-
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule (.*) index.php [qsappend,last]
-
-
diff --git a/web/index.php b/web/index.php
deleted file mode 100644
index fcbce69..0000000
--- a/web/index.php
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php
-
-/**
- * Kolab Server Free/Busy Service Endpoint
- *
- * This is the public API to provide Free/Busy information for Kolab users.
- *
- * @version 0.1.2
- * @author Thomas Bruederli <bruederli at kolabsys.com>
- *
- * Copyright (C) 2013, Kolab Systems AG <contact at kolabsys.com>
- *
- * 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/>.
- */
-
-
-define('KOLAB_FREEBUSY_ROOT', realpath('../'));
-
-// suppress error notices
-ini_set('error_reporting', E_ALL &~ E_NOTICE);
-
-// use composer's autoloader for both dependencies and local lib
-require_once KOLAB_FREEBUSY_ROOT . '/vendor/autoload.php';
-
-use Kolab\Config;
-use Kolab\FreeBusy\Utils;
-use Kolab\FreeBusy\Logger;
-use Kolab\FreeBusy\Directory;
-use Kolab\FreeBusy\HTTPAuth;
-
-
-// load config
-$config = Config::get_instance(KOLAB_FREEBUSY_ROOT . '/config');
-if ($config->valid()) {
- // check for trusted IP first
- $remote_ip = Utils::remoteIP();
- $trusted_ip = $config->trustednetworks ? Utils::checkIPRange($remote_ip, $config->get('trustednetworks.allow', array(), Config::ARR)) : false;
-
- $log = Logger::get('web');
-
- $uri = $_SERVER['REDIRECT_URL'];
-
- // we're not always redirected here
- if (empty($uri)) {
- $uri = $_SERVER['REQUEST_URI'];
- $log->addDebug('Request (direct): ' . $uri, array('ip' => $remote_ip, 'trusted' => $trusted_ip));
- } else {
- $log->addDebug('Request (redirect): ' . $uri, array('ip' => $remote_ip, 'trusted' => $trusted_ip));
- }
-
- // check HTTP authentication
- if (!$trusted_ip && $config->httpauth) {
- if (!HTTPAuth::check($config->httpauth)) {
- $log->addDebug("Abort with 401 Unauthorized");
- header('WWW-Authenticate: Basic realm="Kolab Free/Busy Service"');
- header($_SERVER['SERVER_PROTOCOL'] . " 401 Unauthorized", true);
- exit;
- }
- }
-
- #header('Content-type: text/calendar; charset=utf-8', true);
- header('Content-type: text/plain; charset=utf-8', true);
-
- // analyse request
- $url = array_filter(explode('/', $uri));
- $user = strtolower(array_pop($url));
- $action = strtolower(array_pop($url));
- $extended = false;
-
- // remove file extension
- if (preg_match('/^(.+)\.([ipx]fb)$/i', $user, $m)) {
- $user = $m[1];
- $extended = $m[2] == 'xfb';
- }
-
- // iterate over directories
- foreach ($config->directory as $key => $dirconfig) {
- $log->addDebug("Trying directory $key", $dirconfig);
-
- $directory = Directory::factory($dirconfig);
- if ($directory && ($fbdata = $directory->getFreeBusyData($user, $extended))) {
- $log->addInfo("Found valid data for user $user in directory $key");
- echo $fbdata;
- exit;
- }
- }
-
- // return 404 if request was sent from a trusted IP
- if ($trusted_ip) {
- $log->addDebug("Returning '404 Not Found' for user $user");
- header($_SERVER['SERVER_PROTOCOL'] . " 404 Not found", true);
- }
- else {
- $log->addInfo("Returning empty Free/Busy list for user $user");
-
- $now = time();
- $dtformat = 'Ymd\THis\Z';
-
- // NOTE: The following settings should probably correspond with
- // whatever period of time kolab-freebusyd thinks it should use.
-
- // Should probably be a setting. For now, do 8 weeks in the past
- $start = $now - (60 * 60 * 24 * 7 * 8);
- // Should probably be a setting. For now, do 16 weeks into the future
- $end = $now + (60 * 60 * 24 * 7 * 16);
-
- // Return an apparent empty Free/Busy list.
- print "BEGIN:VCALENDAR\n";
- print "VERSION:2.0\n";
- print "PRODID:-//kolab.org//NONSGML Kolab Server 3//EN\n";
- print "METHOD:PUBLISH\n";
- print "BEGIN:VFREEBUSY\n";
- print "ORGANIZER:MAILTO:" . $user . ".ifb\n";
- print "DTSTAMP:" . gmdate($dtformat) . "\n";
- print "DTSTART:" . gmdate($dtformat, $start) . "\n";
- print "DTEND:" . gmdate($dtformat, $end) . "\n";
- print "COMMENT:This is a dummy vfreebusy that indicates an empty calendar\n";
- print "FREEBUSY:19700101T000000Z/19700101T000000Z\n";
- print "END:VFREEBUSY\n";
- print "END:VCALENDAR\n";
- }
-}
-
-// exit with error
-# header($_SERVER['SERVER_PROTOCOL'] . " 500 Internal Server Error", true);
-
More information about the commits
mailing list