summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-07-25 17:08:18 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-07-25 17:08:18 -0400
commit30b58f56771aa54304069d40a62070c06f5308fc (patch)
treee0bb2bba21c561f96d27bb9cfc09d714aa21d332 /apps/files_external
parent4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78 (diff)
parentf25ccaff59c135d7f1f22196bf266916ef131b35 (diff)
downloadnextcloud-server-30b58f56771aa54304069d40a62070c06f5308fc.tar.gz
nextcloud-server-30b58f56771aa54304069d40a62070c06f5308fc.zip
Merge branch 'master' into share_api
Conflicts: apps/calendar/js/loader.js apps/contacts/index.php apps/contacts/js/loader.js apps/files/js/files.js apps/files_sharing/sharedstorage.php lib/filesystemview.php
Diffstat (limited to 'apps/files_external')
-rwxr-xr-xapps/files_external/lib/dropbox.php2
-rw-r--r--apps/files_external/lib/dropboxtest.php71
-rw-r--r--apps/files_external/lib/google.php9
-rw-r--r--apps/files_external/lib/googletest.php8
-rw-r--r--apps/files_external/lib/smb.php2
-rw-r--r--apps/files_external/lib/webdav.php15
-rw-r--r--apps/files_external/tests/ftp.php1
-rw-r--r--apps/files_external/tests/google.php1
-rw-r--r--apps/files_external/tests/smb.php1
-rw-r--r--apps/files_external/tests/swift.php1
-rw-r--r--apps/files_external/tests/test.php7
-rw-r--r--apps/files_external/tests/webdav.php1
12 files changed, 96 insertions, 23 deletions
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 5d726feddc5..15446ff0bc3 100755
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -208,7 +208,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
if (isset(self::$tempFiles[$tmpFile])) {
$handle = fopen($tmpFile, 'r');
try {
- $response = $this->dropbox->putFile(self::$tempFiles[$tmpFile], $handle);
+ $this->dropbox->putFile(self::$tempFiles[$tmpFile], $handle);
unlink($tmpFile);
} catch (Exception $exception) {
diff --git a/apps/files_external/lib/dropboxtest.php b/apps/files_external/lib/dropboxtest.php
new file mode 100644
index 00000000000..686549e16b8
--- /dev/null
+++ b/apps/files_external/lib/dropboxtest.php
@@ -0,0 +1,71 @@
+<?php
+
+require_once 'dropbox.php';
+// $oauth = new Dropbox_OAuth_Curl('526ar3qlrtzmv65', '3bbn0wo5lzgpjty');
+$dropbox = new OC_Filestorage_Dropbox(array('app_key' => '526ar3qlrtzmv65', 'app_secret' => '3bbn0wo5lzgpjty', 'token' => 'a3ben02jb1y538a', 'token_secret' => 'x60h3fsky21r1b0'));
+$dropbox->rename('/652072main_2012-2897_full (1).jpg', '/test.jpg');
+// $dropbox->test();
+// print_r($dropbox->mkdir('Again'));
+
+// GET&https%3A%2F%2Fapi.dropbox.com%2F1%2Fmetadata%2Fdropbox%2FownCloud&list%3D0%26
+
+// uzpi8oo2rbax1po
+// th9uoso3xxny3ca
+//Step 3: Acquiring access tokens Array ( [token] => 37my637p88ng967 [token_secret] => t49fmgp3omucnnr )
+//The user is authenticated You should really save the oauth tokens somewhere, so the first steps will no longer be needed Array ( [token] => 37my637p88ng967 [token_secret] => t49fmgp3omucnnr )
+
+// For convenience, definitely not required
+// header('Content-Type: text/plain');
+
+// // We need to start a session
+// session_start();
+
+// There are multiple steps in this workflow, we keep a 'state number' here
+// if (isset($_SESSION['state'])) {
+// $state = 2;
+// } else {
+// $state = 1;
+// }
+//
+// switch($state) {
+//
+// /* In this phase we grab the initial request tokens
+// and redirect the user to the 'authorize' page hosted
+// on dropbox */
+// case 1 :
+// echo "Step 1: Acquire request tokens\n";
+// $tokens = $oauth->getRequestToken();
+// print_r($tokens);
+//
+// // Note that if you want the user to automatically redirect back, you can
+// // add the 'callback' argument to getAuthorizeUrl.
+// echo "Step 2: You must now redirect the user to:\n";
+// echo $oauth->getAuthorizeUrl() . "\n";
+// $_SESSION['state'] = 2;
+// $_SESSION['oauth_tokens'] = $tokens;
+// die();
+//
+// /* In this phase, the user just came back from authorizing
+// and we're going to fetch the real access tokens */
+// case 2 :
+// echo "Step 3: Acquiring access tokens\n";
+// $oauth->setToken($_SESSION['oauth_tokens']);
+// $tokens = $oauth->getAccessToken();
+// print_r($tokens);
+// $_SESSION['state'] = 3;
+// $_SESSION['oauth_tokens'] = $tokens;
+// // There is no break here, intentional
+//
+// /* This part gets called if the authentication process
+// already succeeded. We can use our stored tokens and the api
+// should work. Store these tokens somewhere, like a database */
+// case 3 :
+// echo "The user is authenticated\n";
+// echo "You should really save the oauth tokens somewhere, so the first steps will no longer be needed\n";
+// print_r($_SESSION['oauth_tokens']);
+// $oauth->setToken($_SESSION['oauth_tokens']);
+// break;
+//
+// }
+
+?> \ No newline at end of file
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index 1346d899269..02c52ffe04c 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -178,7 +178,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
if ($collection == '/' || $collection == '\.' || $collection == '.') {
$uri = 'https://docs.google.com/feeds/default/private/full';
// Get parent content link
- } else if ($dom = $this->getResource(basename($dir))) {
+ } else if ($dom = $this->getResource(basename($collection))) {
$uri = $dom->getElementsByTagName('content')->item(0)->getAttribute('src');
}
if (isset($uri)) {
@@ -341,7 +341,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
break;
}
}
- $title = basename($path);
+ $title = basename($path2);
// Construct post data
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007" xmlns:gd="http://schemas.google.com/g/2005" gd:etag='.$etag.'>';
@@ -352,13 +352,13 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
} else {
// Move to different collection
if ($collectionEntry = $this->getResource($collection)) {
- $feedUri = $colelctionEntry->getElementsByTagName('content')->item(0)->getAttribute('src');
+ $feedUri = $collectionEntry->getElementsByTagName('content')->item(0)->getAttribute('src');
// Construct post data
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom">';
$postData .= '<id>'.$entry->getElementsByTagName('id')->item(0).'</id>';
$postData .= '</entry>';
- $this->sendRequest($uri, 'POST', $postData);
+ $this->sendRequest($feedUri, 'POST', $postData);
return true;
}
}
@@ -424,7 +424,6 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
}
}
if (!isset($uploadUri) && $entry) {
- $etag = $entry->getAttribute('gd:etag');
$links = $entry->getElementsByTagName('link');
foreach ($links as $link) {
if ($link->getAttribute('rel') == 'http://schemas.google.com/g/2005#resumable-create-media') {
diff --git a/apps/files_external/lib/googletest.php b/apps/files_external/lib/googletest.php
new file mode 100644
index 00000000000..a80af6a0978
--- /dev/null
+++ b/apps/files_external/lib/googletest.php
@@ -0,0 +1,8 @@
+<?php
+
+require_once 'google.php';
+
+// $drive = new OC_Filestorage_Google(array('token' => '4/7nZMlRLlAEeXdY0AeH-eHNCL0YaK', 'token_secret' => 'NqO5VMGUVkwFtOYqHsex4257'));
+// $drive = new OC_Filestorage_Google(array('token' => '1/4Xo84YtTxL2MkQst-Ti3nqF1Isy70NUHDRk-BwsLMf4', 'token_secret' => 'jYnyJ_4-ITNxlX9f9RDNoRW-'));
+// var_export($drive->getFeed('https://docs.google.com/feeds/metadata/default', 'GET'));
+
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index 5e34deb2337..8a5e993b1d0 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -15,8 +15,6 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
private $root;
private $share;
- private static $tempFiles=array();
-
public function __construct($params){
$this->host=$params['host'];
$this->user=$params['user'];
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 675fb9518b1..e3f73c5c0a7 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -77,16 +77,11 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$path=$this->cleanPath($path);
try{
$response=$this->client->propfind($path, array(),1);
- $stripLength=strlen($this->root)+strlen($path);
$id=md5('webdav'.$this->root.$path);
OC_FakeDirStream::$dirs[$id]=array();
- $skip = true;
- foreach($response as $file=>$data){
- // Skip the first file, because it is the current directory
- if ($skip) {
- $skip = false;
- continue;
- }
+ $files=array_keys($response);
+ array_shift($files);//the first entry is the current directory
+ foreach($files as $file){
$file = urldecode(basename($file));
OC_FakeDirStream::$dirs[$id][]=$file;
}
@@ -120,7 +115,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
public function file_exists($path){
$path=$this->cleanPath($path);
try{
- $response=$this->client->propfind($path, array('{DAV:}resourcetype'));
+ $this->client->propfind($path, array('{DAV:}resourcetype'));
return true;//no 404 exception
}catch(Exception $e){
return false;
@@ -201,7 +196,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$mtime=time();
}
$path=$this->cleanPath($path);
- $this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime,));
+ $this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime));
}
public function getFile($path,$target){
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
index 68481b4e66b..97796bca128 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){
}else{
class Test_Filestorage_FTP extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/google.php b/apps/files_external/tests/google.php
index 08116f0e748..806db5a6aaa 100644
--- a/apps/files_external/tests/google.php
+++ b/apps/files_external/tests/google.php
@@ -28,7 +28,6 @@ if(!is_array($config) or !isset($config['google']) or !$config['google']['run'])
class Test_Filestorage_Google extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/smb.php
index e1495b7480d..001ef842276 100644
--- a/apps/files_external/tests/smb.php
+++ b/apps/files_external/tests/smb.php
@@ -14,7 +14,6 @@ if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']){
}else{
class Test_Filestorage_SMB extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/swift.php b/apps/files_external/tests/swift.php
index f0bde6ed605..1520c9473d3 100644
--- a/apps/files_external/tests/swift.php
+++ b/apps/files_external/tests/swift.php
@@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']){
}else{
class Test_Filestorage_SWIFT extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/test.php b/apps/files_external/tests/test.php
new file mode 100644
index 00000000000..bd24404f3b9
--- /dev/null
+++ b/apps/files_external/tests/test.php
@@ -0,0 +1,7 @@
+<?php
+require_once 'files_external/lib/config.php';
+echo "<pre>";
+print_r(OC_Mount_Config::getSystemMountPoints());
+echo "</pre>";
+// OC_Mount_Config::addMountPoint('Photos', 'OC_Filestorage_SWIFT', array('host' => 'gapinthecloud.com', 'user' => 'Gap', 'token' => '23423afdasFJEW22', 'secure' => 'true', 'root' => ''), OC_Mount_Config::MOUNT_TYPE_GROUP, 'admin', false);
+?>
diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/webdav.php
index 144659819b6..14abbef2cbf 100644
--- a/apps/files_external/tests/webdav.php
+++ b/apps/files_external/tests/webdav.php
@@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run'])
}else{
class Test_Filestorage_DAV extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();