Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
afadf93d
Commit
afadf93d
authored
Nov 02, 2012
by
Felix Moeller
Browse files
Checkstyle: many fixes
parent
d9e97610
Changes
83
Hide whitespace changes
Inline
Side-by-side
apps/files/appinfo/filesync.php
View file @
afadf93d
...
...
@@ -36,7 +36,7 @@ if(!OC_User::isLoggedIn()) {
}
}
list
(
$type
,
$file
)
=
explode
(
'/'
,
substr
(
$path_info
,
1
+
strlen
(
$service
)
+
1
),
2
);
list
(
$type
,
$file
)
=
explode
(
'/'
,
substr
(
$path_info
,
1
+
strlen
(
$service
)
+
1
),
2
);
if
(
$type
!=
'oc_chunked'
)
{
OC_Response
::
setStatus
(
OC_Response
::
STATUS_NOT_FOUND
);
...
...
apps/files/download.php
View file @
afadf93d
...
...
@@ -32,7 +32,7 @@ $filename = $_GET["file"];
if
(
!
OC_Filesystem
::
file_exists
(
$filename
))
{
header
(
"HTTP/1.0 404 Not Found"
);
$tmpl
=
new
OCP\Template
(
''
,
'404'
,
'guest'
);
$tmpl
->
assign
(
'file'
,
$filename
);
$tmpl
->
assign
(
'file'
,
$filename
);
$tmpl
->
printPage
();
exit
;
}
...
...
apps/files/index.php
View file @
afadf93d
...
...
@@ -86,7 +86,7 @@ $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize
=
min
(
$upload_max_filesize
,
$post_max_size
);
$freeSpace
=
OC_Filesystem
::
free_space
(
$dir
);
$freeSpace
=
max
(
$freeSpace
,
0
);
$freeSpace
=
max
(
$freeSpace
,
0
);
$maxUploadFilesize
=
min
(
$maxUploadFilesize
,
$freeSpace
);
$permissions
=
OCP\Share
::
PERMISSION_READ
;
...
...
apps/files_encryption/lib/crypt.php
View file @
afadf93d
...
...
@@ -43,7 +43,7 @@ class OC_Crypt {
self
::
init
(
$params
[
'uid'
],
$params
[
'password'
]);
}
public
static
function
init
(
$login
,
$password
)
{
public
static
function
init
(
$login
,
$password
)
{
$view
=
new
OC_FilesystemView
(
'/'
);
if
(
!
$view
->
file_exists
(
'/'
.
$login
))
{
$view
->
mkdir
(
'/'
.
$login
);
...
...
@@ -195,7 +195,7 @@ class OC_Crypt {
public
static
function
blockEncrypt
(
$data
,
$key
=
''
)
{
$result
=
''
;
while
(
strlen
(
$data
))
{
$result
.
=
self
::
encrypt
(
substr
(
$data
,
0
,
8192
),
$key
);
$result
.
=
self
::
encrypt
(
substr
(
$data
,
0
,
8192
),
$key
);
$data
=
substr
(
$data
,
8192
);
}
return
$result
;
...
...
@@ -204,10 +204,10 @@ class OC_Crypt {
/**
* decrypt data in 8192b sized blocks
*/
public
static
function
blockDecrypt
(
$data
,
$key
=
''
,
$maxLength
=
0
)
{
public
static
function
blockDecrypt
(
$data
,
$key
=
''
,
$maxLength
=
0
)
{
$result
=
''
;
while
(
strlen
(
$data
))
{
$result
.
=
self
::
decrypt
(
substr
(
$data
,
0
,
8192
),
$key
);
$result
.
=
self
::
decrypt
(
substr
(
$data
,
0
,
8192
),
$key
);
$data
=
substr
(
$data
,
8192
);
}
if
(
$maxLength
>
0
)
{
...
...
apps/files_encryption/lib/cryptstream.php
View file @
afadf93d
...
...
@@ -106,7 +106,7 @@ class OC_CryptStream{
if
(
$currentPos
%
8192
!=
0
)
{
//make sure we always start on a block start
fseek
(
$this
->
source
,
-
(
$currentPos
%
8192
),
SEEK_CUR
);
$encryptedBlock
=
fread
(
$this
->
source
,
8192
);
$encryptedBlock
=
fread
(
$this
->
source
,
8192
);
fseek
(
$this
->
source
,
-
(
$currentPos
%
8192
),
SEEK_CUR
);
$block
=
OC_Crypt
::
decrypt
(
$encryptedBlock
);
$data
=
substr
(
$block
,
0
,
$currentPos
%
8192
)
.
$data
;
...
...
apps/files_encryption/lib/proxy.php
View file @
afadf93d
...
...
@@ -76,7 +76,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
public
function
postFile_get_contents
(
$path
,
$data
)
{
if
(
self
::
isEncrypted
(
$path
))
{
$cached
=
OC_FileCache_Cached
::
get
(
$path
,
''
);
$data
=
OC_Crypt
::
blockDecrypt
(
$data
,
''
,
$cached
[
'size'
]);
$data
=
OC_Crypt
::
blockDecrypt
(
$data
,
''
,
$cached
[
'size'
]);
}
return
$data
;
}
...
...
@@ -88,30 +88,30 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
$meta
=
stream_get_meta_data
(
$result
);
if
(
self
::
isEncrypted
(
$path
))
{
fclose
(
$result
);
$result
=
fopen
(
'crypt://'
.
$path
,
$meta
[
'mode'
]);
$result
=
fopen
(
'crypt://'
.
$path
,
$meta
[
'mode'
]);
}
elseif
(
self
::
shouldEncrypt
(
$path
)
and
$meta
[
'mode'
]
!=
'r'
and
$meta
[
'mode'
]
!=
'rb'
)
{
if
(
OC_Filesystem
::
file_exists
(
$path
)
and
OC_Filesystem
::
filesize
(
$path
)
>
0
)
{
//first encrypt the target file so we don't end up with a half encrypted file
OCP\Util
::
writeLog
(
'files_encryption'
,
'Decrypting '
.
$path
.
' before writing'
,
OCP\Util
::
DEBUG
);
$tmp
=
fopen
(
'php://temp'
);
OCP\Files
::
streamCopy
(
$result
,
$tmp
);
OCP\Files
::
streamCopy
(
$result
,
$tmp
);
fclose
(
$result
);
OC_Filesystem
::
file_put_contents
(
$path
,
$tmp
);
OC_Filesystem
::
file_put_contents
(
$path
,
$tmp
);
fclose
(
$tmp
);
}
$result
=
fopen
(
'crypt://'
.
$path
,
$meta
[
'mode'
]);
$result
=
fopen
(
'crypt://'
.
$path
,
$meta
[
'mode'
]);
}
return
$result
;
}
public
function
postGetMimeType
(
$path
,
$mime
)
{
public
function
postGetMimeType
(
$path
,
$mime
)
{
if
(
self
::
isEncrypted
(
$path
))
{
$mime
=
OCP\Files
::
getMimeType
(
'crypt://'
.
$path
,
'w'
);
}
return
$mime
;
}
public
function
postStat
(
$path
,
$data
)
{
public
function
postStat
(
$path
,
$data
)
{
if
(
self
::
isEncrypted
(
$path
))
{
$cached
=
OC_FileCache_Cached
::
get
(
$path
,
''
);
$data
[
'size'
]
=
$cached
[
'size'
];
...
...
@@ -119,7 +119,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
return
$data
;
}
public
function
postFileSize
(
$path
,
$size
)
{
public
function
postFileSize
(
$path
,
$size
)
{
if
(
self
::
isEncrypted
(
$path
))
{
$cached
=
OC_FileCache_Cached
::
get
(
$path
,
''
);
return
$cached
[
'size'
];
...
...
apps/files_encryption/settings.php
View file @
afadf93d
...
...
@@ -9,8 +9,8 @@
$tmpl
=
new
OCP\Template
(
'files_encryption'
,
'settings'
);
$blackList
=
explode
(
','
,
OCP\Config
::
getAppValue
(
'files_encryption'
,
'type_blacklist'
,
'jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg'
));
$enabled
=
(
OCP\Config
::
getAppValue
(
'files_encryption'
,
'enable_encryption'
,
'true'
)
==
'true'
);
$tmpl
->
assign
(
'blacklist'
,
$blackList
);
$tmpl
->
assign
(
'encryption_enabled'
,
$enabled
);
$tmpl
->
assign
(
'blacklist'
,
$blackList
);
$tmpl
->
assign
(
'encryption_enabled'
,
$enabled
);
OCP\Util
::
addscript
(
'files_encryption'
,
'settings'
);
OCP\Util
::
addscript
(
'core'
,
'multiselect'
);
...
...
apps/files_encryption/tests/encryption.php
View file @
afadf93d
...
...
@@ -11,46 +11,46 @@ class Test_Encryption extends UnitTestCase {
$key
=
uniqid
();
$file
=
OC
::
$SERVERROOT
.
'/3rdparty/MDB2.php'
;
$source
=
file_get_contents
(
$file
);
//nice large text file
$encrypted
=
OC_Crypt
::
encrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$encrypted
=
OC_Crypt
::
encrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$decrypted
=
rtrim
(
$decrypted
,
"
\0
"
);
$this
->
assertNotEqual
(
$encrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$this
->
assertNotEqual
(
$encrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$chunk
=
substr
(
$source
,
0
,
8192
);
$encrypted
=
OC_Crypt
::
encrypt
(
$chunk
,
$key
);
$chunk
=
substr
(
$source
,
0
,
8192
);
$encrypted
=
OC_Crypt
::
encrypt
(
$chunk
,
$key
);
$this
->
assertEqual
(
strlen
(
$chunk
),
strlen
(
$encrypted
));
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$decrypted
=
rtrim
(
$decrypted
,
"
\0
"
);
$this
->
assertEqual
(
$decrypted
,
$chunk
);
$this
->
assertEqual
(
$decrypted
,
$chunk
);
$encrypted
=
OC_Crypt
::
blockEncrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
);
$this
->
assertNotEqual
(
$encrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$encrypted
=
OC_Crypt
::
blockEncrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
);
$this
->
assertNotEqual
(
$encrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$tmpFileEncrypted
=
OCP\Files
::
tmpFile
();
OC_Crypt
::
encryptfile
(
$file
,
$tmpFileEncrypted
,
$key
);
OC_Crypt
::
encryptfile
(
$file
,
$tmpFileEncrypted
,
$key
);
$encrypted
=
file_get_contents
(
$tmpFileEncrypted
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
);
$this
->
assertNotEqual
(
$encrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
);
$this
->
assertNotEqual
(
$encrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$tmpFileDecrypted
=
OCP\Files
::
tmpFile
();
OC_Crypt
::
decryptfile
(
$tmpFileEncrypted
,
$tmpFileDecrypted
,
$key
);
OC_Crypt
::
decryptfile
(
$tmpFileEncrypted
,
$tmpFileDecrypted
,
$key
);
$decrypted
=
file_get_contents
(
$tmpFileDecrypted
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$file
=
OC
::
$SERVERROOT
.
'/core/img/weather-clear.png'
;
$source
=
file_get_contents
(
$file
);
//binary file
$encrypted
=
OC_Crypt
::
encrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$encrypted
=
OC_Crypt
::
encrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$decrypted
=
rtrim
(
$decrypted
,
"
\0
"
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$encrypted
=
OC_Crypt
::
blockEncrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$encrypted
=
OC_Crypt
::
blockEncrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
);
$this
->
assertEqual
(
$decrypted
,
$source
);
}
...
...
@@ -59,14 +59,14 @@ class Test_Encryption extends UnitTestCase {
$file
=
__DIR__
.
'/binary'
;
$source
=
file_get_contents
(
$file
);
//binary file
$encrypted
=
OC_Crypt
::
encrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$encrypted
=
OC_Crypt
::
encrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
decrypt
(
$encrypted
,
$key
);
$decrypted
=
rtrim
(
$decrypted
,
"
\0
"
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$this
->
assertEqual
(
$decrypted
,
$source
);
$encrypted
=
OC_Crypt
::
blockEncrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
,
strlen
(
$source
));
$this
->
assertEqual
(
$decrypted
,
$source
);
$encrypted
=
OC_Crypt
::
blockEncrypt
(
$source
,
$key
);
$decrypted
=
OC_Crypt
::
blockDecrypt
(
$encrypted
,
$key
,
strlen
(
$source
));
$this
->
assertEqual
(
$decrypted
,
$source
);
}
}
apps/files_encryption/tests/proxy.php
View file @
afadf93d
...
...
@@ -41,7 +41,7 @@ class Test_CryptProxy extends UnitTestCase {
}
public
function
tearDown
()
{
OCP\Config
::
setAppValue
(
'files_encryption'
,
'enable_encryption'
,
$this
->
oldConfig
);
OCP\Config
::
setAppValue
(
'files_encryption'
,
'enable_encryption'
,
$this
->
oldConfig
);
if
(
!
is_null
(
$this
->
oldKey
))
{
$_SESSION
[
'enckey'
]
=
$this
->
oldKey
;
}
...
...
@@ -51,16 +51,16 @@ class Test_CryptProxy extends UnitTestCase {
$file
=
OC
::
$SERVERROOT
.
'/3rdparty/MDB2.php'
;
$original
=
file_get_contents
(
$file
);
OC_Filesystem
::
file_put_contents
(
'/file'
,
$original
);
OC_Filesystem
::
file_put_contents
(
'/file'
,
$original
);
OC_FileProxy
::
$enabled
=
false
;
$stored
=
OC_Filesystem
::
file_get_contents
(
'/file'
);
OC_FileProxy
::
$enabled
=
true
;
$fromFile
=
OC_Filesystem
::
file_get_contents
(
'/file'
);
$this
->
assertNotEqual
(
$original
,
$stored
);
$this
->
assertNotEqual
(
$original
,
$stored
);
$this
->
assertEqual
(
strlen
(
$original
),
strlen
(
$fromFile
));
$this
->
assertEqual
(
$original
,
$fromFile
);
$this
->
assertEqual
(
$original
,
$fromFile
);
}
...
...
@@ -72,46 +72,46 @@ class Test_CryptProxy extends UnitTestCase {
$view
=
new
OC_FilesystemView
(
'/'
.
OC_User
::
getUser
());
$userDir
=
'/'
.
OC_User
::
getUser
()
.
'/files'
;
$rootView
->
file_put_contents
(
$userDir
.
'/file'
,
$original
);
$rootView
->
file_put_contents
(
$userDir
.
'/file'
,
$original
);
OC_FileProxy
::
$enabled
=
false
;
$stored
=
$rootView
->
file_get_contents
(
$userDir
.
'/file'
);
OC_FileProxy
::
$enabled
=
true
;
$this
->
assertNotEqual
(
$original
,
$stored
);
$this
->
assertNotEqual
(
$original
,
$stored
);
$fromFile
=
$rootView
->
file_get_contents
(
$userDir
.
'/file'
);
$this
->
assertEqual
(
$original
,
$fromFile
);
$this
->
assertEqual
(
$original
,
$fromFile
);
$fromFile
=
$view
->
file_get_contents
(
'files/file'
);
$this
->
assertEqual
(
$original
,
$fromFile
);
$this
->
assertEqual
(
$original
,
$fromFile
);
}
public
function
testBinary
()
{
$file
=
__DIR__
.
'/binary'
;
$original
=
file_get_contents
(
$file
);
OC_Filesystem
::
file_put_contents
(
'/file'
,
$original
);
OC_Filesystem
::
file_put_contents
(
'/file'
,
$original
);
OC_FileProxy
::
$enabled
=
false
;
$stored
=
OC_Filesystem
::
file_get_contents
(
'/file'
);
OC_FileProxy
::
$enabled
=
true
;
$fromFile
=
OC_Filesystem
::
file_get_contents
(
'/file'
);
$this
->
assertNotEqual
(
$original
,
$stored
);
$this
->
assertNotEqual
(
$original
,
$stored
);
$this
->
assertEqual
(
strlen
(
$original
),
strlen
(
$fromFile
));
$this
->
assertEqual
(
$original
,
$fromFile
);
$this
->
assertEqual
(
$original
,
$fromFile
);
$file
=
__DIR__
.
'/zeros'
;
$original
=
file_get_contents
(
$file
);
OC_Filesystem
::
file_put_contents
(
'/file'
,
$original
);
OC_Filesystem
::
file_put_contents
(
'/file'
,
$original
);
OC_FileProxy
::
$enabled
=
false
;
$stored
=
OC_Filesystem
::
file_get_contents
(
'/file'
);
OC_FileProxy
::
$enabled
=
true
;
$fromFile
=
OC_Filesystem
::
file_get_contents
(
'/file'
);
$this
->
assertNotEqual
(
$original
,
$stored
);
$this
->
assertNotEqual
(
$original
,
$stored
);
$this
->
assertEqual
(
strlen
(
$original
),
strlen
(
$fromFile
));
}
}
apps/files_encryption/tests/stream.php
View file @
afadf93d
...
...
@@ -15,14 +15,14 @@ class Test_CryptStream extends UnitTestCase {
fclose
(
$stream
);
$stream
=
$this
->
getStream
(
'test1'
,
'r'
,
strlen
(
'foobar'
));
$data
=
fread
(
$stream
,
6
);
$data
=
fread
(
$stream
,
6
);
fclose
(
$stream
);
$this
->
assertEqual
(
'foobar'
,
$data
);
$this
->
assertEqual
(
'foobar'
,
$data
);
$file
=
OC
::
$SERVERROOT
.
'/3rdparty/MDB2.php'
;
$source
=
fopen
(
$file
,
'r'
);
$target
=
$this
->
getStream
(
'test2'
,
'w'
,
0
);
OCP\Files
::
streamCopy
(
$source
,
$target
);
$target
=
$this
->
getStream
(
'test2'
,
'w'
,
0
);
OCP\Files
::
streamCopy
(
$source
,
$target
);
fclose
(
$target
);
fclose
(
$source
);
...
...
@@ -30,7 +30,7 @@ class Test_CryptStream extends UnitTestCase {
$data
=
stream_get_contents
(
$stream
);
$original
=
file_get_contents
(
$file
);
$this
->
assertEqual
(
strlen
(
$original
),
strlen
(
$data
));
$this
->
assertEqual
(
$original
,
$data
);
$this
->
assertEqual
(
$original
,
$data
);
}
/**
...
...
@@ -40,7 +40,7 @@ class Test_CryptStream extends UnitTestCase {
* @param int size
* @return resource
*/
function
getStream
(
$id
,
$mode
,
$size
)
{
function
getStream
(
$id
,
$mode
,
$size
)
{
if
(
$id
===
''
)
{
$id
=
uniqid
();
}
...
...
@@ -50,9 +50,9 @@ class Test_CryptStream extends UnitTestCase {
}
else
{
$file
=
$this
->
tmpFiles
[
$id
];
}
$stream
=
fopen
(
$file
,
$mode
);
$stream
=
fopen
(
$file
,
$mode
);
OC_CryptStream
::
$sourceStreams
[
$id
]
=
array
(
'path'
=>
'dummy'
.
$id
,
'stream'
=>
$stream
,
'size'
=>
$size
);
return
fopen
(
'crypt://streams/'
.
$id
,
$mode
);
return
fopen
(
'crypt://streams/'
.
$id
,
$mode
);
}
function
testBinary
()
{
...
...
@@ -60,26 +60,26 @@ class Test_CryptStream extends UnitTestCase {
$source
=
file_get_contents
(
$file
);
$stream
=
$this
->
getStream
(
'test'
,
'w'
,
strlen
(
$source
));
fwrite
(
$stream
,
$source
);
fwrite
(
$stream
,
$source
);
fclose
(
$stream
);
$stream
=
$this
->
getStream
(
'test'
,
'r'
,
strlen
(
$source
));
$data
=
stream_get_contents
(
$stream
);
fclose
(
$stream
);
$this
->
assertEqual
(
strlen
(
$data
),
strlen
(
$source
));
$this
->
assertEqual
(
$source
,
$data
);
$this
->
assertEqual
(
$source
,
$data
);
$file
=
__DIR__
.
'/zeros'
;
$source
=
file_get_contents
(
$file
);
$stream
=
$this
->
getStream
(
'test2'
,
'w'
,
strlen
(
$source
));
fwrite
(
$stream
,
$source
);
fwrite
(
$stream
,
$source
);
fclose
(
$stream
);
$stream
=
$this
->
getStream
(
'test2'
,
'r'
,
strlen
(
$source
));
$data
=
stream_get_contents
(
$stream
);
fclose
(
$stream
);
$this
->
assertEqual
(
strlen
(
$data
),
strlen
(
$source
));
$this
->
assertEqual
(
$source
,
$data
);
$this
->
assertEqual
(
$source
,
$data
);
}
}
apps/files_external/lib/config.php
View file @
afadf93d
...
...
@@ -256,7 +256,7 @@ class OC_Mount_Config {
foreach
(
$data
[
self
::
MOUNT_TYPE_GROUP
]
as
$group
=>
$mounts
)
{
$content
.
=
"
\t\t
'"
.
$group
.
"' => array (
\n
"
;
foreach
(
$mounts
as
$mountPoint
=>
$mount
)
{
$content
.
=
"
\t\t\t
'"
.
$mountPoint
.
"' => "
.
str_replace
(
"
\n
"
,
''
,
var_export
(
$mount
,
true
))
.
",
\n
"
;
$content
.
=
"
\t\t\t
'"
.
$mountPoint
.
"' => "
.
str_replace
(
"
\n
"
,
''
,
var_export
(
$mount
,
true
))
.
",
\n
"
;
}
$content
.
=
"
\t\t
),
\n
"
;
...
...
apps/files_external/lib/ftp.php
View file @
afadf93d
...
...
@@ -43,7 +43,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$url
.
=
'://'
.
$this
->
user
.
':'
.
$this
->
password
.
'@'
.
$this
->
host
.
$this
->
root
.
$path
;
return
$url
;
}
public
function
fopen
(
$path
,
$mode
)
{
public
function
fopen
(
$path
,
$mode
)
{
switch
(
$mode
)
{
case
'r'
:
case
'rb'
:
...
...
@@ -53,7 +53,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
case
'ab'
:
//these are supported by the wrapper
$context
=
stream_context_create
(
array
(
'ftp'
=>
array
(
'overwrite'
=>
true
)));
return
fopen
(
$this
->
constructUrl
(
$path
),
$mode
,
false
,
$context
);
return
fopen
(
$this
->
constructUrl
(
$path
),
$mode
,
false
,
$context
);
case
'r+'
:
case
'w+'
:
case
'wb+'
:
...
...
@@ -71,10 +71,10 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$tmpFile
=
OCP\Files
::
tmpFile
(
$ext
);
OC_CloseStreamWrapper
::
$callBacks
[
$tmpFile
]
=
array
(
$this
,
'writeBack'
);
if
(
$this
->
file_exists
(
$path
))
{
$this
->
getFile
(
$path
,
$tmpFile
);
$this
->
getFile
(
$path
,
$tmpFile
);
}
self
::
$tempFiles
[
$tmpFile
]
=
$path
;
return
fopen
(
'close://'
.
$tmpFile
,
$mode
);
return
fopen
(
'close://'
.
$tmpFile
,
$mode
);
}
}
...
...
apps/files_external/lib/smb.php
View file @
afadf93d
...
...
@@ -24,14 +24,14 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
if
(
!
$this
->
root
||
$this
->
root
[
0
]
!=
'/'
)
{
$this
->
root
=
'/'
.
$this
->
root
;
}
if
(
substr
(
$this
->
root
,
-
1
,
1
)
!=
'/'
)
{
if
(
substr
(
$this
->
root
,
-
1
,
1
)
!=
'/'
)
{
$this
->
root
.
=
'/'
;
}
if
(
!
$this
->
share
||
$this
->
share
[
0
]
!=
'/'
)
{
$this
->
share
=
'/'
.
$this
->
share
;
}
if
(
substr
(
$this
->
share
,
-
1
,
1
)
==
'/'
)
{
$this
->
share
=
substr
(
$this
->
share
,
0
,
-
1
);
if
(
substr
(
$this
->
share
,
-
1
,
1
)
==
'/'
)
{
$this
->
share
=
substr
(
$this
->
share
,
0
,
-
1
);
}
//create the root folder if necesary
...
...
@@ -42,7 +42,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
public
function
constructUrl
(
$path
)
{
if
(
substr
(
$path
,
-
1
)
==
'/'
)
{
$path
=
substr
(
$path
,
0
,
-
1
);
$path
=
substr
(
$path
,
0
,
-
1
);
}
return
'smb://'
.
$this
->
user
.
':'
.
$this
->
password
.
'@'
.
$this
->
host
.
$this
->
share
.
$this
->
root
.
$path
;
}
...
...
@@ -67,7 +67,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
* @param int $time
* @return bool
*/
public
function
hasUpdated
(
$path
,
$time
)
{
public
function
hasUpdated
(
$path
,
$time
)
{
if
(
!
$path
and
$this
->
root
==
'/'
)
{
//mtime doesn't work for shares, but giving the nature of the backend, doing a full update is still just fast enough
return
true
;
...
...
apps/files_external/lib/streamwrapper.php
View file @
afadf93d
...
...
@@ -50,15 +50,15 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
return
$succes
;
}
public
function
fopen
(
$path
,
$mode
)
{
return
fopen
(
$this
->
constructUrl
(
$path
),
$mode
);
public
function
fopen
(
$path
,
$mode
)
{
return
fopen
(
$this
->
constructUrl
(
$path
),
$mode
);
}
public
function
free_space
(
$path
)
{
return
0
;
}
public
function
touch
(
$path
,
$mtime
=
null
)
{
public
function
touch
(
$path
,
$mtime
=
null
)
{
if
(
is_null
(
$mtime
))
{
$fh
=
$this
->
fopen
(
$path
,
'a'
);
fwrite
(
$fh
,
''
);
...
...
@@ -68,16 +68,16 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{
}
}
public
function
getFile
(
$path
,
$target
)
{
return
copy
(
$this
->
constructUrl
(
$path
),
$target
);
public
function
getFile
(
$path
,
$target
)
{
return
copy
(
$this
->
constructUrl
(
$path
),
$target
);
}
public
function
uploadFile
(
$path
,
$target
)
{
return
copy
(
$path
,
$this
->
constructUrl
(
$target
));
public
function
uploadFile
(
$path
,
$target
)
{
return
copy
(
$path
,
$this
->
constructUrl
(
$target
));
}
public
function
rename
(
$path1
,
$path2
)
{
return
rename
(
$this
->
constructUrl
(
$path1
),
$this
->
constructUrl
(
$path2
));
public
function
rename
(
$path1
,
$path2
)
{
return
rename
(
$this
->
constructUrl
(
$path1
),
$this
->
constructUrl
(
$path2
));
}
public
function
stat
(
$path
)
{
...
...
apps/files_external/lib/swift.php
View file @
afadf93d
...
...
@@ -40,7 +40,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
*/
private
function
getContainerName
(
$path
)
{
$path
=
trim
(
trim
(
$this
->
root
,
'/'
)
.
"/"
.
$path
,
'/.'
);
return
str_replace
(
'/'
,
'\\'
,
$path
);
return
str_replace
(
'/'
,
'\\'
,
$path
);
}
/**
...
...
@@ -189,7 +189,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
* @param string name
* @return bool
*/
private
function
addSubContainer
(
$container
,
$name
)
{
private
function
addSubContainer
(
$container
,
$name
)
{
if
(
!
$name
)
{
return
false
;
}
...
...
@@ -201,16 +201,16 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
foreach
(
$containers
as
&
$sub
)
{
$sub
=
trim
(
$sub
);
}
if
(
array_search
(
$name
,
$containers
)
!==
false
)
{
if
(
array_search
(
$name
,
$containers
)
!==
false
)
{
unlink
(
$tmpFile
);
return
false
;
}
else
{
$fh
=
fopen
(
$tmpFile
,
'a'
);
fwrite
(
$fh
,
$name
.
"
\n
"
);
fwrite
(
$fh
,
$name
.
"
\n
"
);
}
}
catch
(
Exception
$e
)
{
$containers
=
array
();
file_put_contents
(
$tmpFile
,
$name
.
"
\n
"
);
file_put_contents
(
$tmpFile
,
$name
.
"
\n
"
);
}
$obj
->
load_from_filename
(
$tmpFile
);
...
...
@@ -224,7 +224,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
* @param string name
* @return bool
*/
private
function
removeSubContainer
(
$container
,
$name
)
{
private
function
removeSubContainer
(
$container
,
$name
)
{
if
(
!
$name
)
{
return
false
;
}
...
...
@@ -239,13 +239,13 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
foreach
(
$containers
as
&
$sub
)
{
$sub
=
trim
(
$sub
);
}
$i
=
array_search
(
$name
,
$containers
);
$i
=
array_search
(
$name
,
$containers
);
if
(
$i
===
false
)
{
unlink
(
$tmpFile
);
return
false
;
}
else
{
unset
(
$containers
[
$i
]);
file_put_contents
(
$tmpFile
,
implode
(
"
\n
"
,
$containers
)
.
"
\n
"
);
file_put_contents
(
$tmpFile
,
implode
(
"
\n
"
,
$containers
)
.
"
\n
"
);
}
$obj
->
load_from_filename
(
$tmpFile
);
...
...
@@ -337,12 +337,12 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
public
function
opendir
(
$path
)
{
$container
=
$this
->
getContainer
(
$path
);
$files
=
$this
->
getObjects
(
$container
);
$i
=
array_search
(
self
::
SUBCONTAINER_FILE
,
$files
);
$i
=
array_search
(
self
::
SUBCONTAINER_FILE
,
$files
);
if
(
$i
!==
false
)
{
unset
(
$files
[
$i
]);
}
$subContainers
=
$this
->
getSubContainers
(
$container
);
$files
=
array_merge
(
$files
,
$subContainers
);
$files
=
array_merge
(
$files
,
$subContainers
);
$id
=
$this
->
getContainerName
(
$path
);
OC_FakeDirStream
::
$dirs
[
$id
]
=
$files
;
return
opendir
(
'fakedir://'
.
$id
);
...
...
@@ -380,7 +380,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
return
$obj
->
read
();
}