Example #1
0
 /**
  * @details Determines the full request URL, loads all GET & POST parameters
  * to a common variable and loads config files relative to #$dir param.
  *
  * @param string $dir
  *   The base web service directory.
  * @see loadConfig()
  */
 public function __construct($dir)
 {
     $this->dir = $dir;
     $this->url = strtolower(preg_replace('/\\/.*$/', '', $_SERVER['SERVER_PROTOCOL']));
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $this->url .= 's';
     }
     $this->url .= '://' . $_SERVER['SERVER_NAME'];
     if ($_SERVER['SERVER_PORT'] != 80) {
         $this->url .= ':' . $_SERVER['SERVER_PORT'];
     }
     $this->url .= $_SERVER['REQUEST_URI'];
     $this->params = array();
     global $_GET;
     foreach ($_GET as $name => $value) {
         $this->params[$name] = $value;
     }
     global $_POST;
     foreach ($_POST as $name => $value) {
         $this->params[$name] = $value;
     }
     /* Configure */
     $config = array();
     /* ... defaults */
     $config['host'] = IMuSession::getDefaultHost();
     $config['port'] = IMuSession::getDefaultPort();
     /* ... service-specific */
     $this->loadConfig($config);
     $this->config = $config;
     if (array_key_exists('trace-file', $this->config)) {
         IMuTrace::setFile($this->config['trace-file']);
     }
     if (array_key_exists('trace-level', $this->config)) {
         IMuTrace::setLevel($this->config['trace-level']);
     }
 }