]> git.mxchange.org Git - friendica.git/blobdiff - mod/proxy.php
added more curyl braces + spaces between "if" and brace
[friendica.git] / mod / proxy.php
index 4d53c9801c8de3c11c35ef2f4abacfef79646dbb..ff58bba7f1b2dc627bf2ce037cb69bb8da1d470b 100644 (file)
@@ -136,7 +136,7 @@ function proxy_init() {
 
        if (!$direct_cache AND ($cachefile == "")) {
                $r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
-               if (count($r)) {
+               if (dbm::is_result($r)) {
                        $img_str = $r[0]['data'];
                        $mime = $r[0]["desc"];
                        if ($mime == "") $mime = "image/jpeg";
@@ -144,7 +144,7 @@ function proxy_init() {
        } else
                $r = array();
 
-       if (!count($r)) {
+       if (!dbm::is_result($r)) {
                // It shouldn't happen but it does - spaces in URL
                $_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']);
                $redirects = 0;
@@ -255,7 +255,7 @@ function proxy_url($url, $writemode = false, $size = '') {
 
        // Only continue if it isn't a local image and the isn't deactivated
        if (proxy_is_local_image($url)) {
-               $url = str_replace(normalise_link($a->get_baseurl()) . '/', $a->get_baseurl() . '/', $url);
+               $url = str_replace(normalise_link(App::get_baseurl()) . '/', App::get_baseurl() . '/', $url);
                return $url;
        }
 
@@ -264,7 +264,7 @@ function proxy_url($url, $writemode = false, $size = '') {
        }
 
        // Image URL may have encoded ampersands for display which aren't desirable for proxy
-       $url = html_entity_decode($url, ENT_NOQUOTES, 'UTF8');
+       $url = html_entity_decode($url, ENT_NOQUOTES, 'utf-8');
 
        // Creating a sub directory to reduce the amount of files in the cache directory
        $basepath = $a->get_basepath() . '/proxy';
@@ -297,7 +297,7 @@ function proxy_url($url, $writemode = false, $size = '') {
                $longpath .= '.' . $extension;
        }
 
-       $proxypath = $a->get_baseurl() . '/proxy/' . $longpath;
+       $proxypath = App::get_baseurl() . '/proxy/' . $longpath;
 
        if ($size != '') {
                $size = ':' . $size;
@@ -306,9 +306,9 @@ function proxy_url($url, $writemode = false, $size = '') {
        // Too long files aren't supported by Apache
        // Writemode in combination with long files shouldn't be possible
        if ((strlen($proxypath) > 250) AND $writemode) {
-               return hash('md5', $url);
+               return $shortpath;
        } elseif (strlen($proxypath) > 250) {
-               return $a->get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
+               return App::get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
        } elseif ($writemode) {
                return $longpath;
        } else {
@@ -366,7 +366,7 @@ function proxy_img_cb($matches) {
 
 function proxy_parse_html($html) {
        $a = get_app();
-       $html = str_replace(normalise_link($a->get_baseurl())."/", $a->get_baseurl()."/", $html);
+       $html = str_replace(normalise_link(App::get_baseurl())."/", App::get_baseurl()."/", $html);
 
        return preg_replace_callback("/(<img [^>]*src *= *[\"'])([^\"']+)([\"'][^>]*>)/siU", "proxy_img_cb", $html);
 }