aboutsummaryrefslogtreecommitdiffstats
path: root/mod/parse_url.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-02-25 20:06:33 -0800
committerfriendica <info@friendica.com>2013-02-25 20:06:33 -0800
commitc45a8e27638592fc89826097efe07ded31f3c50a (patch)
tree6ff76724684ff36d327afb7a7b4fcd06ce11de4d /mod/parse_url.php
parent46a89910aea43d0af6ace66de315fff87ee2d53a (diff)
downloadvolse-hubzilla-c45a8e27638592fc89826097efe07ded31f3c50a.tar.gz
volse-hubzilla-c45a8e27638592fc89826097efe07ded31f3c50a.tar.bz2
volse-hubzilla-c45a8e27638592fc89826097efe07ded31f3c50a.zip
make sure old fetch_url calls (and those that provided their own curl wrapper) go through z_fetch_url
Diffstat (limited to 'mod/parse_url.php')
-rw-r--r--mod/parse_url.php32
1 files changed, 8 insertions, 24 deletions
diff --git a/mod/parse_url.php b/mod/parse_url.php
index 600d3dc8b..d9bef2fa1 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -55,34 +55,18 @@ function completeurl($url, $scheme) {
function parseurl_getsiteinfo($url) {
$siteinfo = array();
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 0);
- curl_setopt($ch, CURLOPT_TIMEOUT, 3);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.64(Windows NT 5.1; U; de) Presto/2.1.1');
-
- $header = curl_exec($ch);
- curl_close($ch);
-
- // Fetch the first mentioned charset. Can be in body or header
- if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches))
- $charset = trim(array_pop($matches));
- else
- $charset = "utf-8";
- $pos = strpos($header, "\r\n\r\n");
+ $result = z_fetch_url($url);
+ if(! $result['success'])
+ return $siteinfo;
- if ($pos)
- $body = trim(substr($header, $pos));
- else
- $body = $header;
+ $header = $result['header'];
+ $body = $result['body'];
- $body = mb_convert_encoding($body, "UTF-8", $charset);
- $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
+ $body = mb_convert_encoding($body, "UTF-8", $charset);
+ $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
- $doc = new DOMDocument();
+ $doc = new DOMDocument();
@$doc->loadHTML($body);
deletenode($doc, 'style');