url = implode('', array( 'http://', !empty($config['auth']) ? $config['auth'] . '@' : '', $options['host'] . ':' . (!empty($config['port']) ? $config['port'] : $options['port']), $config['path'] )); if (!empty($config['remotepath'])) { $this->remote = $config['remotepath']; } } public function getTargetDir($index) { $indexdir = "{$this->url}/$index"; if (!WebDAV::exists($indexdir)) { WebDAV::mkdir($indexdir); } $targetDir = "{$this->url}/$index/conf"; if (!WebDAV::exists($targetDir)) { WebDAV::mkdir($targetDir); } return $targetDir; } public function uploadFile($index, $file) { $targetDir = $this->getTargetDir($index); WebDAV::upload_from_file($file, $targetDir . '/' . basename($file ?? '')); } public function uploadString($index, $filename, $string) { $targetDir = $this->getTargetDir($index); WebDAV::upload_from_string($string, "$targetDir/$filename"); } public function instanceDir($index) { return $this->remote ? "{$this->remote}/$index" : $index; } }