Пример #1
0
 public function testIsSubpath()
 {
     $folder = Bootstrap::getRandString();
     $subfolder = Bootstrap::getRandString();
     $path = __DIR__ . DIRECTORY_SEPARATOR . $folder;
     $subpath = $path . DIRECTORY_SEPARATOR . $subfolder;
     $create = mkdir($path);
     $this->assertTrue($create);
     $create2 = mkdir($subpath);
     $this->assertTrue($create2);
     $res = DirectoryUtils::isSubpath($path, $subpath);
     $this->assertTrue($res);
     $deleted = rmdir($subpath);
     $this->assertTrue($deleted);
     $deleted2 = rmdir($path);
     $this->assertTrue($deleted2);
 }
 /**
  * Returns true if the asset is in an allowed path
  *
  * @param string $name The path to the asset
  * @return boolean If the asset is in an allowed path will return true.
  */
 public function inAllowedPaths($name)
 {
     $allowedPaths = array_merge($this->getTemplatesPathStack(), $this->getAssetsPaths());
     foreach ($allowedPaths as $path) {
         if (DirectoryUtils::isSubpath($path, $name)) {
             return true;
         }
     }
     return false;
 }