summaryrefslogtreecommitdiffstats
path: root/lib/util.php
diff options
context:
space:
mode:
authorthomas <thomas@thomas-VirtualBox.(none)>2012-11-14 23:14:04 +0100
committerthomas <thomas@thomas-VirtualBox.(none)>2012-11-14 23:14:04 +0100
commit40dd5ae61c8c62cfcda13bd8f8a3b67ff3c980e0 (patch)
treedbb27ae89dea7f93b2ccf6cbf30120dca26d9e7b /lib/util.php
parent847467ab001fadc666770a0d47e909744935aa16 (diff)
downloadnextcloud-server-40dd5ae61c8c62cfcda13bd8f8a3b67ff3c980e0.tar.gz
nextcloud-server-40dd5ae61c8c62cfcda13bd8f8a3b67ff3c980e0.zip
change and transfert getUrlContent
Diffstat (limited to 'lib/util.php')
-rwxr-xr-xlib/util.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php
index 40b44bf9d6e..497b7879227 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -642,4 +642,43 @@ class OC_Util {
return false;
}
+
+ /**
+ * @Brief Get file content via curl.
+ * @param string $url Url to get content
+ * @return string of the response
+ * 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($data);
+
+ } else {
+
+ $ctx = stream_context_create(
+ array(
+ 'http' => array(
+ 'timeout' => 10
+ )
+ )
+ );
+ $data=@file_get_contents($url, 0, $ctx);
+
+ }
+
+ return($data);
+ }
+
}