X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FProxy.php;h=4feb0b680f27ddfcb1a03799d7ba9198a11a0fdd;hb=4b44aca50735dc047e495825bff7dfa717acb615;hp=be70077f15d98b7eb4d14d40a7c71db193a2f4d3;hpb=d4a02dc31408210ab9f67ecac1948dc22b95b8da;p=friendica.git diff --git a/src/Util/Proxy.php b/src/Util/Proxy.php index be70077f15..4feb0b680f 100644 --- a/src/Util/Proxy.php +++ b/src/Util/Proxy.php @@ -2,11 +2,8 @@ namespace Friendica\Util; -use Friendica\BaseModule; -use Friendica\BaseObject; use Friendica\Core\Config; -use Friendica\Core\System; -use Friendica\Util\Strings; +use Friendica\DI; /** * @brief Proxy utilities class @@ -60,11 +57,12 @@ class Proxy * @param string $size One of the ProxyUtils::SIZE_* constants * * @return string The proxyfied URL or relative path + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function proxifyUrl($url, $writemode = false, $size = '') { // Get application instance - $a = BaseObject::getApp(); + $a = DI::app(); // Trim URL first $url = trim($url); @@ -77,7 +75,7 @@ class Proxy // Only continue if it isn't a local image and the isn't deactivated if (self::isLocalImage($url)) { - $url = str_replace(Strings::normaliseLink(System::baseUrl()) . '/', System::baseUrl() . '/', $url); + $url = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/', DI::baseUrl() . '/', $url); return $url; } @@ -110,7 +108,7 @@ class Proxy $longpath .= '.' . $extension; } - $proxypath = System::baseUrl() . '/proxy/' . $longpath; + $proxypath = DI::baseUrl() . '/proxy/' . $longpath; if ($size != '') { $size = ':' . $size; @@ -121,7 +119,7 @@ class Proxy if ((strlen($proxypath) > 250) && $writemode) { return $shortpath; } elseif (strlen($proxypath) > 250) { - return System::baseUrl() . '/proxy/' . $shortpath . '?url=' . urlencode($url); + return DI::baseUrl() . '/proxy/' . $shortpath . '?url=' . urlencode($url); } elseif ($writemode) { return $longpath; } else { @@ -138,10 +136,11 @@ class Proxy * @param string $html Un-proxified HTML code * * @return string Proxified HTML code + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function proxifyHtml($html) { - $html = str_replace(Strings::normaliseLink(System::baseUrl()) . '/', System::baseUrl() . '/', $html); + $html = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/', DI::baseUrl() . '/', $html); return preg_replace_callback('/(]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', 'self::replaceUrl', $html); } @@ -151,6 +150,7 @@ class Proxy * * @param string $url * @return boolean + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ private static function isLocalImage($url) { @@ -163,7 +163,7 @@ class Proxy } // links normalised - bug #431 - $baseurl = Strings::normaliseLink(System::baseUrl()); + $baseurl = Strings::normaliseLink(DI::baseUrl()); $url = Strings::normaliseLink($url); return (substr($url, 0, strlen($baseurl)) == $baseurl); @@ -190,6 +190,7 @@ class Proxy * * @param array $matches Matches from preg_replace_callback() * @return string Proxified HTML image tag + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ private static function replaceUrl(array $matches) {