Ejemplo n.º 1
0
Archivo: SCA.php Proyecto: psagi/sdo
 /**
  * Initialize component
  *
  * @param mixed $calling_component_filename Filename
  *
  * @return null
  */
 public static function initComponent($calling_component_filename)
 {
     //Create the logging mechanism
     self::$logger = SCA_LogFactory::create();
     // Turn on logging here by removing the comment from the following line
     //             self::$logger->startLog();
     self::$logger->log('Entering');
     self::$logger->log("Called from {$calling_component_filename}");
     if (isset($_SERVER['HTTP_HOST'])) {
         self::$logger->log('$_SERVER[\'HTTP_HOST\'] = ' . $_SERVER['HTTP_HOST']);
     }
     if (isset($_SERVER['REQUEST_METHOD'])) {
         self::$logger->log('$_SERVER[\'REQUEST_METHOD\'] = ' . $_SERVER['REQUEST_METHOD']);
     }
     if (isset($_SERVER['CONTENT_TYPE'])) {
         self::$logger->log('$_SERVER[\'CONTENT_TYPE\'] = ' . $_SERVER['CONTENT_TYPE']);
     }
     // contains the X.wsdl in http://..../X.php/X.wsdl
     if (isset($_SERVER['PATH_INFO'])) {
         self::$logger->log('$_SERVER[\'PATH_INFO\'] = ' . $_SERVER['PATH_INFO']);
     }
     if (isset($_SERVER['PHP_SELF'])) {
         self::$logger->log('$_SERVER[\'PHP_SELF\'] = ' . $_SERVER['PHP_SELF']);
     }
     if (isset($_SERVER['REQUEST_URI'])) {
         self::$logger->log('$_SERVER[\'REQUEST_URI\'] = ' . $_SERVER['REQUEST_URI']);
     }
     if (isset($_GET['wsdl'])) {
         self::$logger->log('$_GET[\'wsdl\'] = ' . $_GET['wsdl']);
     }
     /**
      * The instance check around the class - if (!class_exists... -
      * makes sure that we get called here once and once only in any instance
      * of php - i.e. by the first non-SCA client to include SCA, or the target
      * component in a web request.
      *
      * There are three different ways we can find ourselves here.
      * 1. We have been included by a non-SCA client script. It is presumably
      *    later going to call getService() and/or createDataObject().
      * 2. We are the target of an HTTP request for WSDL, SMD, etc. i.e. a service file
      * 3. We are the target of a web request of some sort: WS, JSON, etc.
      *
      * How do we distinguish these to do the right thing?
      * 1. Generate a class name from the name of the including file and see
      *    if it exists. If not, then we are in a plain old client script.
      *    If the class does exist but doesn't have @service then it is still
      *    just a plain old client script.
      * 2. This is a request for a service file if we are the target of an
      *    HTTP request and we have the expected ?wsdl, ?smd etc. on the URL
      * 3. Consider this is a web request otherwise, since we have been included
      *
      * We would get caught out if a non-SCA script were simply to
      * to include a component rather than including SCA and using getService
      * to get a proxy to it.
      */
     if (SCA::_includedByAClientScriptThatIsNotAComponent($calling_component_filename)) {
         SCA::$logger->log('included by a client script that is not a component');
         return;
     }
     $service_description = self::constructServiceDescription($calling_component_filename);
     if (isset($_SERVER['HTTP_HOST'])) {
         $http_host = $_SERVER['HTTP_HOST'];
     } else {
         $http_host = "localhost";
     }
     $service_description->script_name = $_SERVER['SCRIPT_NAME'];
     $service_description->http_host = $http_host;
     foreach ($service_description->binding as $binding_string) {
         SCA::$logger->log("Applying tests for a {$binding_string} binding");
         $request_tester = SCA_Binding_Factory::createRequestTester($binding_string);
         if ($request_tester->isServiceDescriptionRequest($calling_component_filename)) {
             SCA::$logger->log("The request is a service description request for {$binding_string}");
             $service_description_generator = SCA_Binding_Factory::createServiceDescriptionGenerator($binding_string);
             $service_description_generator->generate($service_description);
             SCA::$logger->log('After having generated service description');
             return;
         }
         if ($request_tester->isServiceRequest($calling_component_filename)) {
             SCA::$logger->log("The request is a service request for {$binding_string}");
             $service_request_handler = SCA_Binding_Factory::createServiceRequestHandler($binding_string);
             $service_request_handler->handle($calling_component_filename, $service_description);
             SCA::$logger->log('After having handled service request');
             return;
         }
     }
     /*
     There are other reasons you can get to here - a component loaded
     locally, for example, or loaded as a result of a SOAP request
     but some other component is the real destination.
     None of them are errors though, so nothing needs to be done.
     */
     self::$logger->log('Request was not ATOM, JSON, SOAP, or a request for a .smd or .wsdl file.');
 }
Ejemplo n.º 2
0
 /**
  * Find out which logger to load, and the parameters needed to run it.
  *
  * @return string               The filepath of the logger
  */
 private static function _loggingmode()
 {
     if (false !== ($logger = get_cfg_var('sca.logger'))) {
         return $logger;
     } else {
         return 'SCA/SCA_Logger.php';
     }
     if (false !== ($params = get_cfg_var('sca.logger.parameters'))) {
         self::$paramargs = self::_stringtoarray($params);
     }
 }