コード例 #1
0
ファイル: dav.php プロジェクト: WYSAC/oregon-owncloud
 /**
  * check if a file or folder has been updated since $time
  *
  * @param string $path
  * @param int $time
  * @throws \OCP\Files\StorageNotAvailableException
  * @return bool
  */
 public function hasUpdated($path, $time)
 {
     $this->init();
     $path = $this->cleanPath($path);
     try {
         $response = $this->client->propfind($this->encodePath($path), array('{DAV:}getlastmodified', '{DAV:}getetag', '{http://owncloud.org/ns}permissions'));
         if (isset($response['{DAV:}getetag'])) {
             $cachedData = $this->getCache()->get($path);
             $etag = trim($response['{DAV:}getetag'], '"');
             if ($cachedData['etag'] !== $etag) {
                 return true;
             } else {
                 if (isset($response['{http://owncloud.org/ns}permissions'])) {
                     $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
                     return $permissions !== $cachedData['permissions'];
                 } else {
                     return false;
                 }
             }
         } else {
             $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
             return $remoteMtime > $time;
         }
     } catch (Exception\NotFound $e) {
         return false;
     } catch (Exception $e) {
         throw new StorageNotAvailableException();
     }
 }
コード例 #2
0
ファイル: WebDav.php プロジェクト: DaubaKao/owncloud-core
 public function listFolder($user, $path, $folderDepth)
 {
     $fullUrl = substr($this->baseUrl, 0, -4);
     $settings = array('baseUri' => $fullUrl, 'userName' => $user);
     if ($user === 'admin') {
         $settings['password'] = $this->adminUser[1];
     } else {
         $settings['password'] = $this->regularUser;
     }
     $client = new SClient($settings);
     $response = $client->propfind($this->davPath . "/", array('{DAV:}getetag'), $folderDepth);
     return $response;
 }
コード例 #3
0
ファイル: dav.php プロジェクト: ninjasilicon/core
	/** {@inheritdoc} */
	public function free_space($path) {
		$this->init();
		$path = $this->cleanPath($path);
		try {
			// TODO: cacheable ?
			$response = $this->client->propfind($this->encodePath($path), array('{DAV:}quota-available-bytes'));
			if (isset($response['{DAV:}quota-available-bytes'])) {
				return (int)$response['{DAV:}quota-available-bytes'];
			} else {
				return FileInfo::SPACE_UNKNOWN;
			}
		} catch (\Exception $e) {
			return FileInfo::SPACE_UNKNOWN;
		}
	}
コード例 #4
0
 /**
  * get nodes from adapter backend
  *
  * @param string $path
  * @return array nodes
  */
 private function getNodesFromBackend($path)
 {
     $response = $this->client->propfind($this->encodePath($path), array(), 1);
     $result = array();
     $statNode = true;
     $path = $path === false ? '' : $path;
     foreach ($response as $key => $value) {
         if ($statNode) {
             $nodePath = $path;
             $statNode = false;
         } else {
             $nodePath = $path . '/' . urldecode(basename($key));
         }
         $result[] = $this->rawDataToNode($nodePath, $value);
     }
     return $result;
 }
コード例 #5
0
ファイル: dav.php プロジェクト: adolfo2103/hcloudfilem
 /** {@inheritdoc} */
 public function getPermissions($path)
 {
     $this->init();
     $path = $this->cleanPath($path);
     $response = $this->client->propfind($this->encodePath($path), array('{http://owncloud.org/ns}permissions'));
     if (isset($response['{http://owncloud.org/ns}permissions'])) {
         return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
     } else {
         if ($this->is_dir($path)) {
             return \OCP\Constants::PERMISSION_ALL;
         } else {
             if ($this->file_exists($path)) {
                 return \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE;
             } else {
                 return 0;
             }
         }
     }
 }
コード例 #6
0
ファイル: DAV.php プロジェクト: rchicoli/owncloud-core
 /** {@inheritdoc} */
 public function touch($path, $mtime = null)
 {
     $this->init();
     if (is_null($mtime)) {
         $mtime = time();
     }
     $path = $this->cleanPath($path);
     // if file exists, update the mtime, else create a new empty file
     if ($this->file_exists($path)) {
         try {
             $this->statCache->remove($path);
             $this->client->proppatch($this->encodePath($path), ['{DAV:}lastmodified' => $mtime]);
             // non-owncloud clients might not have accepted the property, need to recheck it
             $response = $this->client->propfind($this->encodePath($path), ['{DAV:}getlastmodified'], 0);
             if (isset($response['{DAV:}getlastmodified'])) {
                 $remoteMtime = strtotime($response['{DAV:}getlastmodified']);
                 if ($remoteMtime !== $mtime) {
                     // server has not accepted the mtime
                     return false;
                 }
             }
         } catch (ClientHttpException $e) {
             if ($e->getHttpStatus() === 501) {
                 return false;
             }
             $this->convertException($e, $path);
             return false;
         } catch (\Exception $e) {
             $this->convertException($e, $path);
             return false;
         }
     } else {
         $this->file_put_contents($path, '');
     }
     return true;
 }
コード例 #7
0
ファイル: cardDav.php プロジェクト: SirLemyDanger/magicmirror
<?php

use Sabre\VObject;
use Sabre\DAV;
include 'vendor/autoload.php';
require_once realpath(dirname(__FILE__) . '/cardDav_connection.php');
$client = new DAV\Client($settings);
$method = filter_input(INPUT_GET, "method");
if (empty($method)) {
    $method = "calDAV";
}
if ($method == "cardDAV") {
    $firstresponse = $client->propfind('/remote.php/carddav/addressbooks/' . $settings["userName"], array('{DAV:}displayname'), 1);
    foreach ($firstresponse as $addressbook => $value) {
        if (empty($value)) {
            continue;
        }
        $response = $client->propfind($addressbook, array('{DAV:}displayname'), 1);
        foreach ($response as $vcardUrl => $value) {
            if ($vcardUrl == $addressbook) {
                continue;
            }
            $vcardresponse = $client->request('GET', $vcardUrl);
            $vcard = VObject\Reader::read($vcardresponse["body"]);
            $name = (string) $vcard->FN;
            $bday_raw = explode("-", (string) $vcard->BDAY);
            if (!empty($bday_raw[0])) {
                $bdays[$name] = mktime(0, 0, 0, $bday_raw[1], $bday_raw[2], $bday_raw[0]) * 1000;
            }
        }
    }