Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
ac3e9627
Commit
ac3e9627
authored
12 years ago
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #375 from tdevos/master
Use curl to get remote file content
parents
9e9bf20b
d2047a00
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/ocsclient.php
+2
-11
2 additions, 11 deletions
lib/ocsclient.php
lib/util.php
+39
-0
39 additions, 0 deletions
lib/util.php
with
41 additions
and
11 deletions
lib/ocsclient.php
+
2
−
11
View file @
ac3e9627
...
...
@@ -55,19 +55,10 @@ class OC_OCSClient{
* This function calls an OCS server and returns the response. It also sets a sane timeout
*/
private
static
function
getOCSresponse
(
$url
)
{
// set a sensible timeout of 10 sec to stay responsive even if the server is down.
$ctx
=
stream_context_create
(
array
(
'http'
=>
array
(
'timeout'
=>
10
)
)
);
$data
=@
file_get_contents
(
$url
,
0
,
$ctx
);
$data
=
\OC_Util
::
getUrlContent
(
$url
);
return
(
$data
);
}
/**
* @brief Get all the categories from the OCS server
* @returns array with category ids
...
...
This diff is collapsed.
Click to expand it.
lib/util.php
+
39
−
0
View file @
ac3e9627
...
...
@@ -669,4 +669,43 @@ class OC_Util {
return
false
;
}
/**
* @Brief Get file content via curl.
* @param string $url Url to get content
* @return string of the response or false on error
* This function get the content of a page via curl, if curl is enabled.
* If not, file_get_element is used.
*/
public
static
function
getUrlContent
(
$url
){
if
(
function_exists
(
'curl_init'
))
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
0
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$curl
,
CURLOPT_CONNECTTIMEOUT
,
10
);
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
$data
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
}
else
{
$ctx
=
stream_context_create
(
array
(
'http'
=>
array
(
'timeout'
=>
10
)
)
);
$data
=@
file_get_contents
(
$url
,
0
,
$ctx
);
}
return
$data
;
}
}
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