[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> rpc.php (source)

   1  <?php
   2  /**
   3   * $Horde: horde/rpc.php,v 1.31 2005/01/03 14:34:43 jan Exp $
   4   *
   5   * Copyright 2002-2005 Jan Schneider <jan@horde.org>
   6   *
   7   * See the enclosed file COPYING for license information (LGPL). If you
   8   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
   9   */
  10  
  11  error_reporting(E_ALL & ~E_NOTICE);
  12  @define('AUTH_HANDLER', true);
  13  @define('HORDE_BASE', dirname(__FILE__).'/phpgwapi/inc/horde/');
  14  require_once HORDE_BASE . '/lib/core.php';
  15  require_once 'Horde/RPC.php';
  16  
  17  $GLOBALS['egw_info'] = array();
  18  $GLOBALS['egw_info']['flags'] = array(
  19      'currentapp'            => 'login',
  20      'noheader'            => True,
  21      'nonavbar'            => True,
  22      'disable_Template_class'    => True
  23  );
  24  include('./header.inc.php');
  25  
  26  $errors = array();
  27  
  28  // SyncML works currently only with PHP sessions
  29  if($GLOBALS['egw_info']['server']['sessions_type'] == 'db')
  30  {
  31      $errors[] = 'SyncML support is currently not available with DB sessions. Please switch to PHP sessions in header.inc.php.';
  32  }
  33  
  34  // SyncML does not support func_overload
  35  if(ini_get('mbstring.func_overload') != 0) {
  36      $errors[] = 'You need to set mbstring.func_overload to 0 for rpc.php.';
  37  }
  38  
  39  // SyncML requires PHP version 5.0.x
  40  if(version_compare(PHP_VERSION, '5.0.0') < 0) {
  41      $errors[] = 'eGroupWare\'s SyncML server requires PHP5. Please update to PHP 5.0.x if you want to use SyncML.';
  42  }
  43  
  44  $config =& CreateObject('phpgwapi.config','syncml');
  45  $config->read_repository();
  46  $GLOBALS['config_syncml'] =& $config->config_data;
  47  unset($config);
  48  
  49  /* Look at the Content-type of the request, if it is available, to try
  50   * and determine what kind of request this is. */
  51  $input = null;
  52  $params = null;
  53  
  54  if (!empty($_SERVER['CONTENT_TYPE'])) {
  55      if (strpos($_SERVER['CONTENT_TYPE'], 'application/vnd.syncml+xml') !== false) {
  56          $serverType = 'syncml';
  57      } elseif (strpos($_SERVER['CONTENT_TYPE'], 'application/vnd.syncml+wbxml') !== false) {
  58          $serverType = 'syncml_wbxml';
  59      } elseif (strpos($_SERVER['CONTENT_TYPE'], 'text/xml') !== false) {
  60          $input = Horde_RPC::getInput();
  61          /* Check for SOAP namespace URI. */
  62          if (strpos($input, 'http://schemas.xmlsoap.org/soap/envelope/') !== false) {
  63              $serverType = 'soap';
  64          } else {
  65              $serverType = 'xmlrpc';
  66          }
  67      } else {
  68          header('HTTP/1.0 501 Not Implemented');
  69          exit;
  70      }
  71  } else {
  72      $serverType = 'soap';
  73  }
  74  
  75  if($serverType != 'syncml' && $serverType != 'syncml_wbxml') {
  76      foreach($errors as $error) {
  77          echo "$error<br>";
  78      }
  79      die('You should access this URL only with a SyncML enabled device.');
  80  } elseif (count($errors) > 0) {
  81      foreach($errors as $error) {
  82          error_log($error);
  83      }
  84      exit;
  85  }
  86  
  87  if ($serverType == 'soap' &&
  88      (!isset($_SERVER['REQUEST_METHOD']) ||
  89       $_SERVER['REQUEST_METHOD'] != 'POST')) {
  90      $session_control = 'none';
  91      if (isset($_GET['wsdl'])) {
  92          $params = 'wsdl';
  93      } else {
  94          $params = 'disco';
  95      }
  96  }
  97  
  98  /* Load base libraries. */
  99  require_once HORDE_BASE . '/lib/base.php';
 100  
 101  /* Load the RPC backend based on $serverType. */
 102  $server = &Horde_RPC::singleton($serverType, $params);
 103  
 104  /* Let the backend check authentication. By default, we look for HTTP
 105   * basic authentication against Horde, but backends can override this
 106   * as needed. */
 107  $server->authorize();
 108  
 109  /* Get the server's response. We call $server->getInput() to allow
 110   * backends to handle input processing differently. */
 111  if ($input === null) {
 112      $input = $server->getInput();
 113  }
 114  
 115  $out = $server->getResponse($input, $params);
 116  
 117  /* Return the response to the client. */
 118  header('Content-Type: ' . $server->getResponseContentType());
 119  header('Content-length: ' . strlen($out));
 120  header('Accept-Charset: UTF-8');
 121  echo $out;


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7