Alex Trofimov 2 лет назад
Родитель
Сommit
4af89e7bd5

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -3946,5 +3946,6 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_page_title_redirect"><![CDATA[Redirect Confirmation]]></string>
     <string name="_sys_page_block_title_redirect"><![CDATA[Confirm redirect]]></string>
     <string name="_sys_redirect_confirmation"><![CDATA[<div class="bx-def-font-h2 bx-def-margin-sec-bottom">You're going to a link outside {1}</div><div class="bx-def-font-small">Link: {0}</div><div class="bx-def-margin-sec-top">Are you sure you want to follow this link?</div>]]></string>
+    <string name="_sys_redirect_confirmation_harmful"><![CDATA[<div class="bx-def-font-h2 bx-def-margin-sec-bottom">You're going to a potentially <b>harmful</b> link {1}</div><div class="bx-def-font-small">Link: {0}</div><div class="bx-def-margin-sec-top">Are you sure you want to follow this link?</div>]]></string>
     <string name="_sys_leave_page_confirmation"><![CDATA[<div class="bx-def-font-h2">Leave the page?</div><div class="bx-def-margin-sec-top">If you do it, your changes will not be saved.</div>]]></string>
 </resources>

+ 1 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -3866,5 +3866,6 @@
   <string name="_sys_page_title_redirect"><![CDATA[Подтверждение перехода на другой сайт]]></string>
   <string name="_sys_page_block_title_redirect"><![CDATA[Подтвердите переход на другой сайт]]></string>
   <string name="_sys_redirect_confirmation"><![CDATA[<div class="bx-def-font-h2 bx-def-margin-sec-bottom">Вы переходите по ссылке за пределы сайта "{1}"</div><div class="bx-def-font-small">Ссылка: {0}</div><div class="bx-def-margin-sec-top">Вы действительно хотите перейти по этой ссылке?</div>]]></string>
+  <string name="_sys_redirect_confirmation_harmful"><![CDATA[<div class="bx-def-font-h2 bx-def-margin-sec-bottom">Вы переходите по <b>опасной</b> ссылке за пределы сайта "{1}"</div><div class="bx-def-font-small">Ссылка: {0}</div><div class="bx-def-margin-sec-top">Вы действительно хотите перейти по этой ссылке?</div>]]></string>
   <string name="_sys_leave_page_confirmation"><![CDATA[<div class="bx-def-font-h2">Покинуть страницу?</div><div class="bx-def-margin-sec-top">Если Вы это сделаете, ваши изменения не будут сохранены.</div>]]></string>
 </resources>

+ 11 - 9
template/scripts/BxBaseServices.php

@@ -1279,10 +1279,16 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
 
     public function serviceRedirect($sUrl = false)
     {
+        if (!getParam('sys_confirmation_before_redirect')) {
+            BxDolTemplate::getInstance()->displayPageNotFound();
+            exit;
+        }
+
         if (false === $sUrl)
             $sUrl = bx_get('url');
 
         if (!$sUrl || !preg_match('@^https?://@', $sUrl)) {
+            http_response_code(500);
             return MsgBox(_t('_error occured'));
         }
         else {
@@ -1290,15 +1296,11 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
             $bSpam = null;
             bx_alert('system', 'check_spam_url', 0, getLoggedId(), array('is_spam' => &$bSpam, 'content' => &$sUrl, 'where' => 'redirect'));
 
-            if (false === $bSpam) {
-                header('Location: ' . $sUrl);
-            } 
-            elseif (true === $bSpam || null === $bSpam) {
-                return BxDolTemplate::getInstance()->parseHtmlByName('redirect.html', [
-                    'text' => _t('_sys_redirect_confirmation', bx_process_output($sUrl), getParam('site_title')),
-                    'url' => bx_js_string($sUrl, BX_ESCAPE_STR_APOS),
-                ]);
-            }
+            $sLangKey = $bSpam ? '_sys_redirect_confirmation_harmful' : '_sys_redirect_confirmation';
+            return BxDolTemplate::getInstance()->parseHtmlByName('redirect.html', [
+                'text' => _t($sLangKey, bx_process_output($sUrl), getParam('site_title')),
+                'url' => bx_js_string($sUrl, BX_ESCAPE_STR_APOS),
+            ]);
         }
     }