new example code
authorLars Kneschke <l.kneschke@metaways.de>
Wed, 9 May 2012 04:48:26 +0000 (06:48 +0200)
committerLars Kneschke <l.kneschke@metaways.de>
Wed, 9 May 2012 04:48:26 +0000 (06:48 +0200)
Change-Id: Ib6cc3c61228c4838e36aa667ce63e7d09a9d6459

docs/syncroton.php [new file with mode: 0644]

diff --git a/docs/syncroton.php b/docs/syncroton.php
new file mode 100644 (file)
index 0000000..523df9c
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**\r
+ * Syncroton\r
+ *
+ * Example server file
+ *\r
+ * @package     doc\r
+ * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3\r
+ * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)\r
+ * @author      Lars Kneschke <l.kneschke@metaways.de>
+ * @todo        still untested\r
+ */\r
+
+if(empty($_SERVER['PHP_AUTH_USER'])) {\r
+    header('WWW-Authenticate: Basic realm="Syncroton"');\r
+    header('HTTP/1.1 401 Unauthorized');\r
+    return;\r
+}
+
+$paths = array(
+    realpath(dirname(__FILE__)),
+    realpath(dirname(__FILE__) . '/lib'),
+    get_include_path()
+);
+set_include_path(implode(PATH_SEPARATOR, $paths));
+
+require_once 'Zend/Loader/Autoloader.php';
+$autoloader = Zend_Loader_Autoloader::getInstance();
+$autoloader->setFallbackAutoloader(true);
+
+// authenticate user here if needed
+// authentication is not part of Syncroton
+
+// set database backend
+$params = array (\r
+    'dbname' => '/tmp/syncroton.sq3',\r
+);\r
+Syncroton_Registry::setDatabase(Zend_Db::factory('PDO_SQLITE', $params));\r
+
+// setup logger
+$writer = new Zend_Log_Writer_Stream('/tmp/syncroton.log');\r
+$writer->addFilter(new Zend_Log_Filter_Priority(Zend_Log::DEBUG));
+\r
+$logger = new Zend_Log($writer);
+\r
+Syncroton_Registry::set('loggerBackend', $logger);\r
+
+// set the classes to handle contacts, events, email and tasks \r
+Syncroton_Registry::setContactsDataClass('Syncroton_Data_Contacts');\r
+Syncroton_Registry::setCalendarDataClass('Syncroton_Data_Calendar');\r
+Syncroton_Registry::setEmailDataClass('Syncroton_Data_Email');\r
+Syncroton_Registry::setTasksDataClass('Syncroton_Data_Tasks');\r
+
+$server = new Syncroton_Server($_SERVER['PHP_AUTH_USER']);\r
+\r
+$server->handle();
\ No newline at end of file