2005-06-19 16:35:40 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* $Horde: horde/rpc.php,v 1.31 2005/01/03 14:34:43 jan Exp $
|
|
|
|
*
|
|
|
|
* Copyright 2002-2005 Jan Schneider <jan@horde.org>
|
|
|
|
*
|
|
|
|
* See the enclosed file COPYING for license information (LGPL). If you
|
|
|
|
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
|
|
|
|
*/
|
|
|
|
|
2005-07-20 14:00:02 +02:00
|
|
|
error_reporting(E_ALL & ~E_NOTICE);
|
2005-06-19 16:35:40 +02:00
|
|
|
@define('AUTH_HANDLER', true);
|
2010-02-03 13:28:49 +01:00
|
|
|
@define('EGW_API_INC', dirname(__FILE__) . '/phpgwapi/inc/');
|
|
|
|
@define('HORDE_BASE', EGW_API_INC . '/horde/');
|
2005-06-19 16:35:40 +02:00
|
|
|
require_once HORDE_BASE . '/lib/core.php';
|
|
|
|
require_once 'Horde/RPC.php';
|
2010-02-03 13:28:49 +01:00
|
|
|
//require_once EGW_API_INC . '/common_functions.inc.php';
|
2005-06-19 16:35:40 +02:00
|
|
|
|
2006-10-03 17:18:03 +02:00
|
|
|
$GLOBALS['egw_info'] = array(
|
|
|
|
'flags' => array(
|
2010-02-03 13:28:49 +01:00
|
|
|
'currentapp' => 'syncml',
|
|
|
|
'noheader' => true,
|
|
|
|
'nonavbar' => true,
|
|
|
|
'noapi' => true,
|
|
|
|
'disable_Template_class' => true,
|
|
|
|
),
|
|
|
|
'server' => array(
|
|
|
|
'show_domain_selectbox' => true,
|
|
|
|
),
|
2005-06-19 16:35:40 +02:00
|
|
|
);
|
|
|
|
|
2010-02-03 13:28:49 +01:00
|
|
|
|
|
|
|
include('./header.inc.php');
|
2008-07-16 11:29:13 +02:00
|
|
|
|
2006-04-09 12:08:13 +02:00
|
|
|
$errors = array();
|
|
|
|
|
2005-12-23 08:00:30 +01:00
|
|
|
// SyncML works currently only with PHP sessions
|
|
|
|
if($GLOBALS['egw_info']['server']['sessions_type'] == 'db')
|
|
|
|
{
|
2006-04-09 12:08:13 +02:00
|
|
|
$errors[] = 'SyncML support is currently not available with DB sessions. Please switch to PHP sessions in header.inc.php.';
|
2005-12-23 08:00:30 +01:00
|
|
|
}
|
|
|
|
|
2006-04-09 12:08:13 +02:00
|
|
|
// SyncML does not support func_overload
|
2006-04-07 13:51:57 +02:00
|
|
|
if(ini_get('mbstring.func_overload') != 0) {
|
2006-04-09 12:08:13 +02:00
|
|
|
$errors[] = 'You need to set mbstring.func_overload to 0 for rpc.php.';
|
2006-04-07 10:09:42 +02:00
|
|
|
}
|
|
|
|
|
2006-04-09 12:08:13 +02:00
|
|
|
// SyncML requires PHP version 5.0.x
|
2006-04-07 13:51:57 +02:00
|
|
|
if(version_compare(PHP_VERSION, '5.0.0') < 0) {
|
2006-04-09 12:08:13 +02:00
|
|
|
$errors[] = 'eGroupWare\'s SyncML server requires PHP5. Please update to PHP 5.0.x if you want to use SyncML.';
|
2006-04-07 10:09:42 +02:00
|
|
|
}
|
|
|
|
|
2005-06-19 16:35:40 +02:00
|
|
|
/* Look at the Content-type of the request, if it is available, to try
|
|
|
|
* and determine what kind of request this is. */
|
|
|
|
$input = null;
|
|
|
|
$params = null;
|
|
|
|
|
|
|
|
if (!empty($_SERVER['CONTENT_TYPE'])) {
|
|
|
|
if (strpos($_SERVER['CONTENT_TYPE'], 'application/vnd.syncml+xml') !== false) {
|
|
|
|
$serverType = 'syncml';
|
|
|
|
} elseif (strpos($_SERVER['CONTENT_TYPE'], 'application/vnd.syncml+wbxml') !== false) {
|
2009-12-02 23:22:54 +01:00
|
|
|
// switching output compression off, as it makes problems with synthesis client
|
|
|
|
ini_set('zlib.output_compression',0);
|
2005-06-19 16:35:40 +02:00
|
|
|
$serverType = 'syncml_wbxml';
|
|
|
|
} elseif (strpos($_SERVER['CONTENT_TYPE'], 'text/xml') !== false) {
|
|
|
|
$input = Horde_RPC::getInput();
|
|
|
|
/* Check for SOAP namespace URI. */
|
|
|
|
if (strpos($input, 'http://schemas.xmlsoap.org/soap/envelope/') !== false) {
|
|
|
|
$serverType = 'soap';
|
|
|
|
} else {
|
|
|
|
$serverType = 'xmlrpc';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
header('HTTP/1.0 501 Not Implemented');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$serverType = 'soap';
|
|
|
|
}
|
|
|
|
|
2006-03-18 09:06:10 +01:00
|
|
|
if($serverType != 'syncml' && $serverType != 'syncml_wbxml') {
|
2006-04-09 12:08:13 +02:00
|
|
|
foreach($errors as $error) {
|
|
|
|
echo "$error<br>";
|
2006-04-07 13:51:57 +02:00
|
|
|
}
|
|
|
|
die('You should access this URL only with a SyncML enabled device.');
|
2006-04-09 12:08:13 +02:00
|
|
|
} elseif (count($errors) > 0) {
|
|
|
|
foreach($errors as $error) {
|
|
|
|
error_log($error);
|
|
|
|
}
|
|
|
|
exit;
|
2006-03-18 09:06:10 +01:00
|
|
|
}
|
|
|
|
|
2005-06-19 16:35:40 +02:00
|
|
|
if ($serverType == 'soap' &&
|
|
|
|
(!isset($_SERVER['REQUEST_METHOD']) ||
|
|
|
|
$_SERVER['REQUEST_METHOD'] != 'POST')) {
|
|
|
|
$session_control = 'none';
|
|
|
|
if (isset($_GET['wsdl'])) {
|
|
|
|
$params = 'wsdl';
|
|
|
|
} else {
|
|
|
|
$params = 'disco';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load base libraries. */
|
|
|
|
require_once HORDE_BASE . '/lib/base.php';
|
|
|
|
|
|
|
|
/* Load the RPC backend based on $serverType. */
|
|
|
|
$server = &Horde_RPC::singleton($serverType, $params);
|
|
|
|
|
|
|
|
/* Let the backend check authentication. By default, we look for HTTP
|
|
|
|
* basic authentication against Horde, but backends can override this
|
|
|
|
* as needed. */
|
|
|
|
$server->authorize();
|
|
|
|
|
|
|
|
/* Get the server's response. We call $server->getInput() to allow
|
|
|
|
* backends to handle input processing differently. */
|
|
|
|
if ($input === null) {
|
|
|
|
$input = $server->getInput();
|
|
|
|
}
|
2006-04-07 10:09:42 +02:00
|
|
|
|
2005-06-19 16:35:40 +02:00
|
|
|
$out = $server->getResponse($input, $params);
|
|
|
|
|
|
|
|
/* Return the response to the client. */
|
|
|
|
header('Content-Type: ' . $server->getResponseContentType());
|
2007-09-29 11:17:42 +02:00
|
|
|
header('Content-length: ' . bytes($out));
|
2005-06-19 16:35:40 +02:00
|
|
|
header('Accept-Charset: UTF-8');
|
|
|
|
echo $out;
|