Example #1
0
 public function __construct($params)
 {
     $host = $params['host'];
     //remove leading http[s], will be generated in createBaseUri()
     if (substr($host, 0, 8) == "https://") {
         $host = substr($host, 8);
     } else {
         if (substr($host, 0, 7) == "http://") {
             $host = substr($host, 7);
         }
     }
     $this->host = $host;
     $this->user = $params['user'];
     $this->password = $params['password'];
     $this->secure = isset($params['secure']) && $params['secure'] == 'true' ? true : false;
     $this->root = isset($params['root']) ? $params['root'] : '/';
     if (!$this->root || $this->root[0] != '/') {
         $this->root = '/' . $this->root;
     }
     if (substr($this->root, -1, 1) != '/') {
         $this->root .= '/';
     }
     $settings = array('baseUri' => $this->createBaseUri(), 'userName' => $this->user, 'password' => $this->password);
     $this->client = new OC_Connector_Sabre_Client($settings);
     if ($caview = \OCP\Files::getStorage('files_external')) {
         $certPath = \OCP\Config::getSystemValue('datadirectory') . $caview->getAbsolutePath("") . 'rootcerts.crt';
         if (file_exists($certPath)) {
             $this->client->addTrustedCertificates($certPath);
         }
     }
     //create the root folder if necesary
     $this->mkdir('');
 }
Example #2
0
 private function init()
 {
     if ($this->ready) {
         return;
     }
     $this->ready = true;
     $settings = array('baseUri' => $this->createBaseUri(), 'userName' => $this->user, 'password' => $this->password);
     $this->client = new \Sabre_DAV_Client($settings);
     if ($this->secure === true && $this->certPath) {
         $this->client->addTrustedCertificates($this->certPath);
     }
 }
Example #3
0
 private function init()
 {
     if ($this->ready) {
         return;
     }
     $this->ready = true;
     $settings = array('baseUri' => $this->createBaseUri(), 'userName' => $this->user, 'password' => $this->password);
     $this->client = new \Sabre_DAV_Client($settings);
     $caview = \OCP\Files::getStorage('files_external');
     if ($caview) {
         $certPath = \OCP\Config::getSystemValue('datadirectory') . $caview->getAbsolutePath("") . 'rootcerts.crt';
         if (file_exists($certPath)) {
             $this->client->addTrustedCertificates($certPath);
         }
     }
 }