コード例 #1
0
 /**
  * Checks if this file is a child of the given filebase
  * directory.
  * @param mixed sfFilebaseDirectory | string $file
  */
 public function fileLiesWithin($file, $container)
 {
     $file = $this->getFilebaseFile($file);
     $container = $this->getFilebaseFile($container);
     // file = /path/to/lalala/bumsdi
     // container = /path/to
     if (strpos(sfFilebasePluginUtil::unifySlashes($file->getPathname()), sfFilebasePluginUtil::unifySlashes($container->getPathname()) . '/') === 0) {
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * Returns filename, as seen absolutely from webroot.
  *
  * @throws sfFilebasePluginException
  * @return string $path
  */
 public function getAbsolutePathFromWebroot()
 {
     if (!$this->getFilebase()->isInFilebase($this)) {
         throw new sfFilebasePluginException(sprintf('Path %s does not lie within FilebaseDirectory', $this->getPathname()));
     }
     $path = '/' . ltrim(preg_replace('#^' . sfFilebasePluginUtil::unifySlashes($_SERVER['DOCUMENT_ROOT']) . '#i', '', sfFilebasePluginUtil::unifySlashes($this->getPathname())), '/\\');
     return $path;
 }