Beispiel #1
0
 /**
  * Constructs a new LocalFileSystem.
  *
  * @param string $scheme File scheme.
  * @param MOXMAN_Util_Config $config Config instance for file system.
  * @param string $root Root path for file system.
  */
 public function __construct($scheme, MOXMAN_Util_Config $config, $root)
 {
     parent::__construct($scheme, $config, $root);
     // Force the root path to an absolute path
     $this->rootPath = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $this->rootPath);
     // Get wwwroot from config or resolve it, remove trailing slash.
     $wwwroot = preg_replace('/\\/$/', '', $config->get("filesystem.local.wwwroot"));
     if (!$wwwroot) {
         $sitePaths = MOXMAN_Util_PathUtils::getSitePaths();
         $wwwroot = $sitePaths["wwwroot"];
     }
     // If rootpath isn't within the resolved wwwroot then resolve the rootpath
     if (!MOXMAN_Util_PathUtils::isChildOf($this->rootPath, $wwwroot)) {
         $this->rootPath = realpath($this->rootPath);
         if (!$this->rootPath) {
             throw new MOXMAN_Exception("Configured filesystem.rootpath doesn't exist or couldn't be resolved.");
         } else {
             if (!MOXMAN_Util_PathUtils::isChildOf($this->rootPath, $wwwroot)) {
                 throw new MOXMAN_Exception("The filesystem.rootpath isn't within the auto detected wwwroot." . "You need to configure filesystem.local.wwwroot.");
             }
         }
     }
     $this->setFileConfigProvider(new MOXMAN_Vfs_Local_FileConfigProvider($this, $config));
     $this->setFileUrlProvider(new MOXMAN_Vfs_Local_FileUrlProvider());
     $this->setFileUrlResolver(new MOXMAN_Vfs_Local_FileUrlResolver($this));
 }
Beispiel #2
0
 /**
  * Constructs a new memory file system.
  *
  * @param string $scheme File scheme.
  * @param MOXMAN_Util_Config $config Config instance for file system.
  * @param string $root Root path for file system.
  */
 public function __construct($scheme, MOXMAN_Util_Config $config, $root)
 {
     parent::__construct($scheme, $config, $root);
     $this->entries = array();
     $this->pathLookup = array();
     $this->addEntry($root, array("isFile" => false));
 }
Beispiel #3
0
 public function close()
 {
     parent::close();
     if (is_resource($this->connection)) {
         ftp_close($this->connection);
         $this->connection = null;
     }
 }
 /**
  * Returns a meta data instance for the current file.
  *
  * @return MOXMAN_Vfs_FileMetaData Meta data instance for the file.
  */
 public function getMetaData()
 {
     if (!$this->meta) {
         $provider = $this->fileSystem->getFileMetaDataProvider();
         $this->meta = $provider->getMetaData($this);
     }
     return $this->meta;
 }
 /**
  * Constructs a new memory file system.
  *
  * @param string $scheme File scheme.
  * @param MOXMAN_Util_Config $config Config instance for file system.
  * @param string $root Root path for file system.
  */
 public function __construct($scheme, MOXMAN_Util_Config $config, $root)
 {
     parent::__construct($scheme, $config, $root);
     $this->entries = array();
     $this->pathLookup = array();
     $this->addEntry($root, array("isFile" => false));
     $this->setFileUrlResolver(new MOXMAN_Vfs_Memory_FileUrlResolver($this));
 }
Beispiel #6
0
 /**
  * Constructs a new LocalFileSystem.
  *
  * @param string $scheme File scheme.
  * @param MOXMAN_Util_Config $config Config instance for file system.
  * @param string $root Root path for file system.
  */
 public function __construct($scheme, MOXMAN_Util_Config $config, $root)
 {
     parent::__construct($scheme, $config, $root);
     // Force the root path to an absolute path
     $this->rootPath = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $this->rootPath);
     $this->setFileConfigProvider(new MOXMAN_Vfs_Local_FileConfigProvider($this, $config));
     $this->setFileUrlProvider(new MOXMAN_Vfs_Local_FileUrlProvider());
     $this->setFileUrlResolver(new MOXMAN_Vfs_Local_FileUrlResolver($this));
 }
Beispiel #7
0
 /**
  * Constructs a new Azure instance.
  *
  * @param String $scheme File system protocol scheme.
  * @param MOXMAN_Util_Config $config Config instance for file system.
  * @param String $root Root path for file system.
  */
 public function __construct($scheme, $config, $root)
 {
     parent::__construct($scheme, $config, $root);
     $this->setFileUrlResolver(new MOXMAN_Azure_FileUrlResolver($this));
     // Parse URL and get containers
     $url = parse_url($this->getRootPath());
     $containerName = $url["host"];
     $this->containerConfigPrefix = "azure.containers." . $containerName . ".";
     $this->setContainerOption("key", $containerName);
     $containerName = $this->getContainerOption("container", $containerName);
     $this->setContainerOption("name", $containerName);
     // Handle development mode
     if ($this->getContainerOption("development")) {
         $this->setContainerOption("url", "http://127.0.0.1:10000");
         $this->setContainerOption("account", "devstoreaccount1");
         $this->setContainerOption("sharedkey", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==");
     }
     // Verify that container is valid
     $account = $this->getContainerOption("account");
     if (!$account || !$this->getContainerOption("sharedkey")) {
         throw new MOXMAN_Exception("Could not find account/sharedkey options for container " . $containerName . ".");
     }
     if (!$this->getContainerOption("url")) {
         $this->setContainerOption("url", "http://" . $account . ".blob.core.windows.net");
         $urlprefix = $this->getContainerOption("urlprefix");
         if (!$urlprefix) {
             $this->setContainerOption("urlprefix", "http://" . $account . ".blob.core.windows.net/" . $containerName);
         } else {
             // Normalize urlprefix and add container
             $url = parse_url($urlprefix);
             if (!isset($url["path"]) || $url["path"] == "/") {
                 $url["path"] = "/" . $this->getContainerOption("name");
             }
             $urlprefix = MOXMAN_Util_Url::buildUrl($url);
             $this->setContainerOption("urlprefix", $urlprefix);
         }
         $this->setContainerOption("path", "/" . $containerName);
     } else {
         $this->setContainerOption("path", "/" . $account . "/" . $containerName);
         $this->setContainerOption("urlprefix", "http://localhost:10000/devstoreaccount1/");
     }
     // Setup HTTP client
     $this->httpClient = new MOXMAN_Http_HttpClient($this->getContainerOption("url"));
     // Debug output
     if ($this->getContainerOption("debug_level") > 0) {
         $this->httpClient->setLogFunction(array($this, "logHttpClient"));
         $this->httpClient->setLogLevel($this->getContainerOption("debug_level"));
     }
 }
Beispiel #8
0
 /**
  * Constructs a new AmazonS3 instance.
  *
  * @param String $scheme File system protocol scheme.
  * @param MOXMAN_Util_Config $config Config instance for file system.
  * @param String $root Root path for file system.
  */
 public function __construct($scheme, $config, $root)
 {
     parent::__construct($scheme, $config, $root);
     $this->cache = new MOXMAN_Util_LfuCache();
     $this->setFileUrlResolver(new MOXMAN_AmazonS3_FileUrlResolver($this));
     // Parse URL and get buckets
     $url = parse_url($this->getRootPath());
     $bucketName = $url["host"];
     $bucketKey = $bucketName;
     $this->bucketConfigPrefix = "amazons3.buckets." . $bucketName . ".";
     $bucketName = $this->getBucketOption("bucket", $bucketName);
     $this->client = new MOXMAN_AmazonS3_Client(array("bucket" => $bucketName, "endpoint" => $this->getBucketOption("endpoint"), "publickey" => $this->getBucketOption("publickey"), "privatekey" => $this->getBucketOption("secretkey"), "acl" => $this->getBucketOption("acl", "public-read"), "cache_control" => $this->getBucketOption("acl", "cache_control"), "proxy" => $config->get("general.http_proxy"), "scheme" => $this->getBucketOption("scheme", "tls")));
     // Setup urlprefix
     $urlPrefix = $this->getBucketOption("urlprefix");
     if (!$urlPrefix) {
         $info = $this->client->getInfo();
         $this->setBucketOption("urlprefix", "//" . $info["endpoint"]);
     }
     if ($this->getBucketOption("debug_level") > 0) {
         $this->client->setLogFunction(array($this, "logHttpClient"));
         $this->client->setLogLevel($this->getBucketOption("debug_level"));
     }
     $this->setBucketOption("key", $bucketKey);
 }