namespace Friendica\Util;
-use Friendica\BaseModule;
-use Friendica\BaseObject;
use Friendica\Core\Config;
-use Friendica\Core\System;
+use Friendica\DI;
/**
* @brief Proxy utilities class
* @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);
// Only continue if it isn't a local image and the isn't deactivated
if (self::isLocalImage($url)) {
- $url = str_replace(normalise_link(System::baseUrl()) . '/', System::baseUrl() . '/', $url);
+ $url = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/', DI::baseUrl() . '/', $url);
return $url;
}
$longpath .= '.' . $extension;
}
- $proxypath = System::baseUrl() . '/proxy/' . $longpath;
+ $proxypath = DI::baseUrl() . '/proxy/' . $longpath;
if ($size != '') {
$size = ':' . $size;
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 {
* @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(normalise_link(System::baseUrl()) . '/', System::baseUrl() . '/', $html);
+ $html = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/', DI::baseUrl() . '/', $html);
return preg_replace_callback('/(<img [^>]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', 'self::replaceUrl', $html);
}
*
* @param string $url
* @return boolean
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function isLocalImage($url)
{
}
// links normalised - bug #431
- $baseurl = normalise_link(System::baseUrl());
- $url = normalise_link($url);
+ $baseurl = Strings::normaliseLink(DI::baseUrl());
+ $url = Strings::normaliseLink($url);
return (substr($url, 0, strlen($baseurl)) == $baseurl);
}
*
* @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)
{