Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
080a6223
Commit
080a6223
authored
9 years ago
by
Robin Appelman
Committed by
Lukas Reschke
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
use ocs discover endpoint to test remote
parent
52d217d7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files_sharing/lib/controllers/externalsharescontroller.php
+17
-4
17 additions, 4 deletions
...iles_sharing/lib/controllers/externalsharescontroller.php
apps/files_sharing/lib/external/storage.php
+10
-4
10 additions, 4 deletions
apps/files_sharing/lib/external/storage.php
with
27 additions
and
8 deletions
apps/files_sharing/lib/controllers/externalsharescontroller.php
+
17
−
4
View file @
080a6223
...
...
@@ -96,9 +96,10 @@ class ExternalSharesController extends Controller {
* Test whether the specified remote is accessible
*
* @param string $remote
* @param bool $checkVersion
* @return bool
*/
protected
function
testUrl
(
$remote
)
{
protected
function
testUrl
(
$remote
,
$checkVersion
=
false
)
{
try
{
$client
=
$this
->
clientService
->
newClient
();
$response
=
json_decode
(
$client
->
get
(
...
...
@@ -109,7 +110,11 @@ class ExternalSharesController extends Controller {
]
)
->
getBody
());
return
!
empty
(
$response
->
version
)
&&
version_compare
(
$response
->
version
,
'7.0.0'
,
'>='
);
if
(
$checkVersion
)
{
return
!
empty
(
$response
->
version
)
&&
version_compare
(
$response
->
version
,
'7.0.0'
,
'>='
);
}
else
{
return
is_object
(
$response
);
}
}
catch
(
\Exception
$e
)
{
return
false
;
}
...
...
@@ -124,9 +129,17 @@ class ExternalSharesController extends Controller {
* @return DataResponse
*/
public
function
testRemote
(
$remote
)
{
if
(
$this
->
testUrl
(
'https://'
.
$remote
.
'/status.php'
))
{
if
(
$this
->
testUrl
(
'https://'
.
$remote
.
'/ocs-provider'
)
||
$this
->
testUrl
(
'https://'
.
$remote
.
'/ocs-provider/index.php'
)
||
$this
->
testUrl
(
'https://'
.
$remote
.
'/status.php'
,
true
)
)
{
return
new
DataResponse
(
'https'
);
}
elseif
(
$this
->
testUrl
(
'http://'
.
$remote
.
'/status.php'
))
{
}
elseif
(
$this
->
testUrl
(
'http://'
.
$remote
.
'/ocs-provider'
)
||
$this
->
testUrl
(
'http://'
.
$remote
.
'/ocs-provider/index.php'
)
||
$this
->
testUrl
(
'http://'
.
$remote
.
'/status.php'
,
true
)
)
{
return
new
DataResponse
(
'http'
);
}
else
{
return
new
DataResponse
(
false
);
...
...
This diff is collapsed.
Click to expand it.
apps/files_sharing/lib/external/storage.php
+
10
−
4
View file @
080a6223
...
...
@@ -218,20 +218,26 @@ class Storage extends DAV implements ISharedStorage {
}
/**
* check if the configured remote is a valid
ownCloud instance
* check if the configured remote is a valid
federated share provider
*
* @return bool
*/
protected
function
testRemote
()
{
try
{
$
re
sult
=
file_get_contents
(
$this
->
remote
.
'/
status
.php'
)
;
$data
=
json_decode
(
$result
);
return
is_object
(
$data
)
and
!
empty
(
$data
->
version
);
re
turn
$this
->
testRemoteUrl
(
$this
->
remote
.
'/
ocs-provider/index
.php'
)
||
$this
->
testRemoteUrl
(
$this
->
remote
.
'/ocs-provider'
)
||
$this
->
testRemoteUrl
(
$this
->
remote
.
'/status.php'
);
}
catch
(
\Exception
$e
)
{
return
false
;
}
}
private
function
testRemoteUrl
(
$url
)
{
$result
=
file_get_contents
(
$url
);
$data
=
json_decode
(
$result
);
return
(
is_object
(
$data
)
and
!
empty
(
$data
->
version
));
}
/**
* @return mixed
* @throws ForbiddenException
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment