PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/soap.php

https://github.com/eeggenberger/ezpublish
PHP | 123 lines | 63 code | 27 blank | 33 comment | 5 complexity | a6602d04ab1a4a8d6dadebbb65f02d14 MD5 | raw file
  1. <?php
  2. /**
  3. * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
  4. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
  5. * @version //autogentag//
  6. * @package kernel
  7. */
  8. /*!
  9. \brief The SOAP file will handle all eZ Publish soap requests.
  10. SOAP functions are
  11. */
  12. ob_start();
  13. ini_set( "display_errors" , "0" );
  14. // Set a default time zone if none is given. The time zone can be overriden
  15. // in config.php or php.ini.
  16. if ( !ini_get( "date.timezone" ) )
  17. {
  18. date_default_timezone_set( "UTC" );
  19. }
  20. require 'autoload.php';
  21. /*!
  22. Reads settings from site.ini and passes them to eZDebug.
  23. */
  24. function eZUpdateDebugSettings()
  25. {
  26. $ini = eZINI::instance();
  27. list( $debugSettings['debug-enabled'], $debugSettings['debug-by-ip'], $debugSettings['debug-by-user'], $debugSettings['debug-ip-list'], $debugSettings['debug-user-list'] ) =
  28. $ini->variableMulti( 'DebugSettings', array( 'DebugOutput', 'DebugByIP', 'DebugByUser', 'DebugIPList', 'DebugUserIDList' ), array ( 'enabled', 'enabled', 'enabled' ) );
  29. eZDebug::updateSettings( $debugSettings );
  30. }
  31. $ini = eZINI::instance();
  32. // Initialize/set the index file.
  33. eZSys::init( 'soap.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' );
  34. $uri = eZURI::instance( eZSys::requestURI() );
  35. $GLOBALS['eZRequestedURI'] = $uri;
  36. // Check for extension
  37. require_once( 'kernel/common/ezincludefunctions.php' );
  38. eZExtension::activateExtensions( 'default' );
  39. // Extension check end
  40. // Activate correct siteaccess
  41. $soapINI = eZINI::instance( 'soap.ini' );
  42. if ( $soapINI->variable( 'GeneralSettings', 'UseDefaultAccess' ) === 'enabled' )
  43. {
  44. $access = array( 'name' => $ini->variable( 'SiteSettings', 'DefaultAccess' ),
  45. 'type' => eZSiteAccess::TYPE_DEFAULT );
  46. }
  47. else
  48. {
  49. $access = eZSiteAccess::match( $uri,
  50. eZSys::hostname(),
  51. eZSys::serverPort(),
  52. eZSys::indexFile() );
  53. }
  54. $access = eZSiteAccess::change( $access );
  55. // Siteaccess activation end
  56. // Check for activating Debug by user ID (Final checking. The first was in eZDebug::updateSettings())
  57. eZDebug::checkDebugByUser();
  58. // Check for siteaccess extension
  59. eZExtension::activateExtensions( 'access' );
  60. // Siteaccess extension check end
  61. // Now that all extensions are activated and siteaccess has been changed, reset
  62. // all eZINI instances as they may not take into account siteaccess specific settings.
  63. eZINI::resetAllInstances( false );
  64. /*!
  65. Reads settings from i18n.ini and passes them to eZTextCodec.
  66. */
  67. function eZUpdateTextCodecSettings()
  68. {
  69. $ini = eZINI::instance( 'i18n.ini' );
  70. list( $i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension'] ) =
  71. $ini->variableMulti( 'CharacterSettings', array( 'Charset', 'HTTPCharset', 'MBStringExtension' ), array( false, false, 'enabled' ) );
  72. eZTextCodec::updateSettings( $i18nSettings );
  73. }
  74. // Initialize text codec settings
  75. eZUpdateTextCodecSettings();
  76. // Initialize module loading
  77. $moduleRepositories = eZModule::activeModuleRepositories();
  78. eZModule::setGlobalPathList( $moduleRepositories );
  79. // Load soap extensions
  80. $enableSOAP = $soapINI->variable( 'GeneralSettings', 'EnableSOAP' );
  81. if ( $enableSOAP == 'true' )
  82. {
  83. // Login if we have username and password.
  84. if ( eZHTTPTool::username() and eZHTTPTool::password() )
  85. eZUser::loginUser( eZHTTPTool::username(), eZHTTPTool::password() );
  86. $server = new eZSOAPServer();
  87. foreach( $soapINI->variable( 'ExtensionSettings', 'SOAPExtensions' ) as $extension )
  88. {
  89. include_once( eZExtension::baseDirectory() . '/' . $extension . '/soap/initialize.php' );
  90. }
  91. $server->processRequest();
  92. }
  93. ob_end_flush();
  94. eZExecution::cleanExit();
  95. ?>