Пример #1
0
 /**
  * Calculates the uri for a request, making sure that the base uri is stripped out
  *
  * @param string $uri
  * @throws Sabre_DAV_Exception_Forbidden A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri
  * @return string
  */
 public function calculateUri($uri)
 {
     if ($uri[0] != '/' && strpos($uri, '://')) {
         $uri = parse_url($uri, PHP_URL_PATH);
     }
     $uri = str_replace('//', '/', $uri);
     if (strpos($uri, $this->getBaseUri()) === 0) {
         return trim(Sabre_DAV_URLUtil::decodePath(substr($uri, strlen($this->getBaseUri()))), '/');
         // A special case, if the baseUri was accessed without a trailing
         // slash, we'll accept it as well.
     } elseif ($uri . '/' === $this->getBaseUri()) {
         return '';
     } else {
         throw new Sabre_DAV_Exception_Forbidden('Requested uri (' . $uri . ') is out of base uri (' . $this->getBaseUri() . ')');
     }
 }
Пример #2
0
 /**
  * This testcase was sent by a bug reporter
  *
  * @depends testDecode
  */
 function testDecodeAccentsWindows7()
 {
     $str = '/webdav/%C3%A0fo%C3%B3';
     $newStr = Sabre_DAV_URLUtil::decodePath($str);
     $this->assertEquals(strtolower($str), Sabre_DAV_URLUtil::encodePath($newStr));
 }
Пример #3
0
 /**
  * Calculates the uri for a request, making sure that the base uri is stripped out 
  * 
  * @param string $uri 
  * @throws Sabre_DAV_Exception_PermissionDenied A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri
  * @return string
  */
 public function calculateUri($uri)
 {
     if ($uri[0] != '/' && strpos($uri, '://')) {
         $uri = parse_url($uri, PHP_URL_PATH);
     }
     $uri = str_replace('//', '/', $uri);
     if (strpos($uri, $this->baseUri) === 0) {
         return trim(Sabre_DAV_URLUtil::decodePath(substr($uri, strlen($this->baseUri))), '/');
     } else {
         throw new Sabre_DAV_Exception_PermissionDenied('Requested uri (' . $uri . ') is out of base uri (' . $this->baseUri . ')');
     }
 }
Пример #4
0
 /**
  * set session options
  * 
  * @param array $_options
  */
 public static function setSessionOptions($_options = array())
 {
     Zend_Session::setOptions(array_merge($_options, array('cookie_httponly' => true, 'hash_function' => 1)));
     if (isset($_SERVER['REQUEST_URI'])) {
         // cut of path behind caldav/webdav (removeme when dispatching is refactored)
         if (isset($_SERVER['REDIRECT_WEBDAV']) && $_SERVER['REDIRECT_WEBDAV'] == 'true') {
             $decodedUri = Sabre_DAV_URLUtil::decodePath($_SERVER['REQUEST_URI']);
             $baseUri = '/' . substr($decodedUri, 0, strpos($decodedUri, 'webdav/') + strlen('webdav/'));
         } else {
             if (isset($_SERVER['REDIRECT_CALDAV']) && $_SERVER['REDIRECT_CALDAV'] == 'true') {
                 $decodedUri = Sabre_DAV_URLUtil::decodePath($_SERVER['REQUEST_URI']);
                 $baseUri = '/' . substr($decodedUri, 0, strpos($decodedUri, 'caldav/') + strlen('caldav/'));
             } else {
                 $baseUri = dirname($_SERVER['REQUEST_URI']);
             }
         }
         if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
             $baseUri = '/' . $_SERVER['HTTP_HOST'] . ($baseUri == '/' ? '' : $baseUri);
         }
         // fix for windows server with backslash directory separator
         $baseUri = str_replace(DIRECTORY_SEPARATOR, '/', $baseUri);
         Zend_Session::setOptions(array('cookie_path' => $baseUri));
     }
     if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) != 'OFF') {
         Zend_Session::setOptions(array('cookie_secure' => true));
     }
 }