protected function getRequestUri() { // separate path and query-string $requestUri = explode('?', rawurldecode(Curry_URL::getRequestUri()), 2); // remove matching base path $baseUrl = Curry_URL::getDefaultBaseUrl(); $basePath = $baseUrl['path']; if ($basePath === $requestUri[0]) { $requestUri[0] = '/'; } else { if (Curry_String::startsWith($requestUri[0], $basePath)) { $requestUri[0] = substr($requestUri[0], strlen($basePath)); } } return join('?', $requestUri); }
/** * Create a relative path from one path to another. * * @param string $from * @param string $to * @return string */ public static function getRelativePath($from, $to) { $from = self::getAbsolutePath($from); $to = self::getAbsolutePath($to); $relative = ""; while ($from && $from !== $to && !Curry_String::startsWith($to, $from . '/')) { $relative .= '../'; $from = dirname($from); if ($from == '/') { break; } } if ($from !== $to) { $relative .= substr($to, strlen($from) + 1) . '/'; } return $relative; }
/** * Check if physical path is writable based on FilebrowserAccess. * * @param string $physical * @return bool */ public static function isPhysicalWritable($physical) { $roots = self::getRoots(); foreach ($roots as $root) { if ($root['writable'] && Curry_String::startsWith($physical . '/', $root['realpath'] . '/')) { return true; } } return false; }