From: Roland Häder Date: Tue, 31 Jul 2018 02:06:22 +0000 (+0200) Subject: [WIP] Rewrite to Proxy class: (#5507) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4d39164c1ee6de2b1a09c2a1a8a4c89531d47ee5;p=friendica.git [WIP] Rewrite to Proxy class: (#5507) * Rewrite to Proxy class: - introduced new Friendica\Network\Proxy class for in exchange of proxy_*() functions - moved also all PROXY_* constants there as Proxy::* - removed now no longer needed mod/proxy.php loading as composer's auto-load will do this for us - renamed those proxy_*() functions to better names: + proxy_init() -> Proxy::init() (public) + proxy_url() -> Proxy::proxifyUrl() (public) + proxy_parse_html() -> Proxy::proxifyHtml() (public) + proxy_is_local_image() -> Proxy::isLocalImage() (private) + proxy_parse_query() -> Proxy::parseQuery() (private) + proxy_img_cb() -> Proxy::replaceUrl() (private) * Ops, need to set $a here ... * CR request: - moved Proxy class to Friendica\Module - extended BaseModule * Ops, no need for own instance of $a when self::getApp() is around. * Proxy-rewrite: - proxy_url() and proxy_parse_html() are both non-module functions (now methods) - so they must be splitted into a seperate class - also the SIZE_* and DEFAULT_TIME constants are both not relevant to module * No instances from utility classes * Fixed error: - proxify*() is now located in `Friendica\Util\ProxyUtils` * Moved back to original place, ops? How did they move here? Well, it was not intended by me. * Removed duplicate (left-over from split) constants and static array. Thank to MrPetovan finding it. * Renamed ProxyUtils -> Proxy and aliased it back to ProxyUtils. --- diff --git a/include/api.php b/include/api.php index c00578cdf0..4fbbc37779 100644 --- a/include/api.php +++ b/include/api.php @@ -40,6 +40,7 @@ use Friendica\Object\Image; use Friendica\Protocol\Diaspora; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\XML; require_once 'include/conversation.php'; @@ -47,7 +48,6 @@ require_once 'mod/share.php'; require_once 'mod/item.php'; require_once 'include/security.php'; require_once 'mod/wall_upload.php'; -require_once 'mod/proxy.php'; define('API_METHOD_ANY', '*'); define('API_METHOD_GET', 'GET'); @@ -2518,7 +2518,7 @@ function api_get_entitities(&$text, $bbcode) preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images); foreach ($images[1] as $image) { - $replace = proxy_url($image); + $replace = ProxyUtils::proxifyUrl($image); $text = str_replace($image, $replace, $text); } return []; @@ -2627,7 +2627,7 @@ function api_get_entitities(&$text, $bbcode) // If image cache is activated, then use the following sizes: // thumb (150), small (340), medium (600) and large (1024) if (!Config::get("system", "proxy_disabled")) { - $media_url = proxy_url($url); + $media_url = ProxyUtils::proxifyUrl($url); $sizes = []; $scale = Image::getScalingDimensions($image[0], $image[1], 150); diff --git a/include/conversation.php b/include/conversation.php index 89bc4b5478..5addb610c7 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -20,6 +20,7 @@ use Friendica\Model\Term; use Friendica\Object\Post; use Friendica\Object\Thread; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Temporal; use Friendica\Util\XML; @@ -407,7 +408,6 @@ function visible_activity($item) { * */ function conversation(App $a, array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) { - require_once 'mod/proxy.php'; $ssl_state = ((local_user()) ? true : false); @@ -418,8 +418,10 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o if (local_user()) { $str_blocked = PConfig::get(local_user(), 'system', 'blocked'); + if ($str_blocked) { $arr_blocked = explode(',', $str_blocked); + for ($x = 0; $x < count($arr_blocked); $x ++) { $arr_blocked[$x] = trim($arr_blocked[$x]); } @@ -477,6 +479,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o } } elseif ($mode === 'notes') { $profile_owner = local_user(); + if (!$update) { $live_update_div = '
' . "\r\n" . "