RomanL 4 лет назад
Родитель
Сommit
75f8956cc1

+ 35 - 0
em.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+require_once('./inc/header.inc.php');
+
+$aEmbedData = BxDolPage::getEmbedData(bx_get('url'));
+    
+$aResult = [
+    'version' => '1.0',
+    'type' => 'rich',
+    'title' => $aEmbedData['title'],
+    'url' => $aEmbedData['url'],
+    'provider_name' => getParam('site_title'),
+    'provider_url' => BX_DOL_URL_ROOT,
+    'html' => $aEmbedData['html'],
+];
+        
+if ($aEmbedData['thumbnail_url']){
+    $aResult['thumbnail_url'] = $aEmbedData['thumbnail_url'];
+}
+if ($aEmbedData['author_name']){
+    $aResult['author_name'] =  $aEmbedData['author_name'];
+}
+if ($aEmbedData['author_url']){
+    $aResult['author_url'] =  $aEmbedData['author_url'];
+}
+        
+header('Content-Type: application/json; charset=utf-8');
+        
+echo json_encode($aResult);

+ 15 - 3
inc/classes/BxDolPage.php

@@ -495,16 +495,28 @@ class BxDolPage extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
         $aUrl = parse_url($sUrl);
         $aUri = explode('/', $aUrl['path']);
         $aParams = [];
+        $sUri = $aUri[2];
+        
+        if ('/' !== $aUrl['path'] && getParam('permalinks_seo_links')){
+            $sUri = $aUri[1];
+            $sPageName = BxDolPageQuery::getPageObjectNameByURI($sUri);
+            $aPage = $sPageName ? BxDolPageQuery::getPageObject($sPageName) : false;
+            if (!empty($aUri[2])) { 
+                $r = BxDolPageQuery::getSeoLink($aPage['module'], $sUri, ['uri' => $aUri[2]]);
+                if ($r)
+                    $aParams[$r['param_name']] = $r['param_value'];    
+            }
+        }
         
         if (isset($aUrl['query']))
             parse_str($aUrl['query'], $aParams);
         
-        if (!$aUri || empty($aUri[2]))
+        if (!$aUri || empty($sUri))
             return [];
         
         $sAuthorName = $sAuthorUrl = $sThumb = '';
         if (isset($aParams['id'])){
-            $sContentInfoObject = BxDolPageQuery::getContentInfoObjectNameByURI($aUri[2]);
+            $sContentInfoObject = BxDolPageQuery::getContentInfoObjectNameByURI($sUri);
             $oContentInfo = BxDolContentInfo::getObjectInstance($sContentInfoObject);
             
             $sTitle = $oContentInfo->getContentTitle($aParams['id']);
@@ -516,7 +528,7 @@ class BxDolPage extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
             
         }
         else{
-            $oPage = BxDolPage::getObjectInstanceByURI($aUri[2], false, true);
+            $oPage = BxDolPage::getObjectInstanceByURI($sUri, false, true);
             $aPage = $oPage->getObject();
             $sTitle = _t($aPage['title']);
             $sHtml = BxDolTemplate::getInstance()->parseHtmlByName('embed.html', [

+ 2 - 1
inc/classes/BxDolTemplate.php

@@ -840,13 +840,14 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
      */
     function getEmbed($sContent)
     {
+        header('Content-Security-Policy: frame-ancestors ' . getParam('sys_csp_frame_ancestors')) ;
+        
         $this->addJs(['inc/js/|embed.js']);
         $this->addCss(['embed.css']);
         
         $this->setPageNameIndex (BX_PAGE_EMBED);
         $this->setPageContent('page_main_code', '<div class="bx-embed">' . $sContent . '</div>');
         $this->getPageCode();
-        
     }
 
     /**

+ 26 - 0
inc/js/functions.js

@@ -1305,4 +1305,30 @@ function bx_regexp_escape(s)
         .replace(/-/mg, '\\x2d');
 }
 
+function bx_copy_to_clipboard(s) 
+{
+    console.log(s);
+    if (window.clipboardData && window.clipboardData.setData) {
+        return window.clipboardData.setData("Text", text);
+
+    }
+    else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
+        var textarea = document.createElement("textarea");
+        textarea.textContent = s;
+        textarea.style.position = "fixed";  // Prevent scrolling to bottom of page in Microsoft Edge.
+        document.body.appendChild(textarea);
+        textarea.select();
+        try {
+            return document.execCommand("copy");  // Security exception may be thrown by some browsers.
+        }
+        catch (ex) {
+            console.warn("Copy to clipboard failed.", ex);
+            return prompt("Copy to clipboard: Ctrl+C, Enter", text);
+        }
+        finally {
+            document.body.removeChild(textarea);
+        }
+    }
+}
+
 /** @} */

+ 1 - 1
inc/utils.inc.php

@@ -913,7 +913,7 @@ function bx_file_get_contents($sFileUrl, $aParams = array(), $sMethod = 'get', $
             curl_setopt($rConnect, CURLOPT_TIMEOUT, $iTimeout);
         }
         
-        if(getParam('curl_ssl_allow_untrusted') == 'on'){
+        if(getParam('sys_curl_ssl_allow_untrusted') == 'on'){
             curl_setopt($rConnect, CURLOPT_SSL_VERIFYPEER, false);
             curl_setopt($rConnect, CURLOPT_SSL_VERIFYHOST, false);
         }

+ 3 - 1
install/sql/system.sql

@@ -338,7 +338,9 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'sys_logs_storage_default', '_adm_stg_cpt_option_sys_logs_storage_default', 'Folder', 'select', 'Folder,PHPLog,STDErr', '', '', '', 130),
 
 (@iCategoryId, 'sys_default_curl_timeout', '_adm_stg_cpt_option_sys_default_curl_timeout', '300', 'digit', '', '', '', '', 140),
-(@iCategoryId, 'curl_ssl_allow_untrusted', '_adm_stg_cpt_option_sys_ssl_allow_untrusted', '', 'checkbox', '', '', '', '', 145);
+(@iCategoryId, 'sys_curl_ssl_allow_untrusted', '_adm_stg_cpt_option_sys_ssl_allow_untrusted', '', 'checkbox', '', '', '', '', 145),
+
+(@iCategoryId, 'sys_csp_frame_ancestors', '_adm_stg_cpt_option_sys_csp_frame_ancestors', '*', 'digit', '', '', '', '', 150);
 
 --
 -- CATEGORY (HIDDEN): System

+ 5 - 3
modules/boonex/artificer/data/template/system/designbox_share_popup.html

@@ -1,13 +1,15 @@
 <div class="bx-db-share-popup">
     <div class="bx-db-share-popup-cnt">
-         <bx_menu:sys_social_sharing />
+         <div class="mb-4">
+             <bx_menu:sys_social_sharing />
+         </div>
          <div class="mb-4">
              <bx_text:_sys_txt_share_popup_url />       
-             <div class="block w-full py-2 px-3 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm bg-white dark:bg-gray-900 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-2 focus:text-gray-900 dark:focus:text-gray-100 focus:ring-blue-500 focus:border-opacity-70 focus:ring-opacity-20 focus:border-blue-500 text-sm text-gray-700 dark:text-gray-300 appearance-none p-2 rounded ">__url__</div>
+             <div class="block w-full py-2 px-3 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm bg-white dark:bg-gray-900 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-2 focus:text-gray-900 dark:focus:text-gray-100 focus:ring-blue-500 focus:border-opacity-70 focus:ring-opacity-20 focus:border-blue-500 text-sm text-gray-700 dark:text-gray-300 appearance-none p-2 rounded" onClick="bx_copy_to_clipboard('__url__')" title="<bx_text:_sys_txt_share_popup_copy_to_clipboard_text />">__url__</div>
          </div>
          <div class="mb-4">
              <bx_text:_sys_txt_share_popup_embeded_code />        
-             <div class="block w-full py-2 px-3 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm bg-white dark:bg-gray-900 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-2 focus:text-gray-900 dark:focus:text-gray-100 focus:ring-blue-500 focus:border-opacity-70 focus:ring-opacity-20 focus:border-blue-500 text-sm text-gray-700 dark:text-gray-300 appearance-none p-2 rounded">__code__</div> 
+             <div class="block w-full py-2 px-3 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm bg-white dark:bg-gray-900 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-2 focus:text-gray-900 dark:focus:text-gray-100 focus:ring-blue-500 focus:border-opacity-70 focus:ring-opacity-20 focus:border-blue-500 text-sm text-gray-700 dark:text-gray-300 appearance-none p-2 rounded" onClick="bx_copy_to_clipboard('__code__')" title="<bx_text:_sys_txt_share_popup_copy_to_clipboard_text />">__code__</div> 
          </div>
     </div>
 </div>

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

@@ -1611,6 +1611,7 @@
   	<string name="_adm_stg_cpt_option_sys_session_lifetime_in_min"><![CDATA[Session lifetime (min)]]></string>
 	<string name="_adm_stg_cpt_option_sys_default_curl_timeout"><![CDATA[cURL - default timeout]]></string>
     <string name="_adm_stg_cpt_option_sys_ssl_allow_untrusted"><![CDATA[cURL - trust unsigned certificates or not verified hosts]]></string>
+    <string name="_adm_stg_cpt_option_sys_csp_frame_ancestors"><![CDATA['Content-Security-Policy: frame-ancestors' header value]]></string>
 	<string name="_adm_stg_cpt_option_template"><![CDATA[Default Template]]></string>
 	<string name="_adm_stg_err_option_template"><![CDATA[Template cannot be empty and must have a valid name.]]></string>
     <string name="_adm_stg_cpt_option_use_like_operator"><![CDATA[Use operator LIKE for search (recommended for small content)]]></string>
@@ -3452,6 +3453,7 @@ If it is not enabled then please consider implement this optimization, since it
         <string name="_sys_txt_reports_grid_view_notes"><![CDATA[View notes]]></string>
         <string name="_sys_txt_share_popup_header"><![CDATA[Share]]></string>
         <string name="_sys_txt_share_popup_url"><![CDATA[URL]]></string>
+        <string name="_sys_txt_share_popup_copy_to_clipboard_text"><![CDATA[Click for copy to the clipboard]]></string>
         <string name="_sys_txt_share_popup_embeded_code"><![CDATA[Embeded code]]></string>
         <string name="_sys_unconfirmed"><![CDATA[Unconfirmed]]></string>
 	<string name="_sys_upgrade_conclusion"><![CDATA[<h3>Important info:</h3><p>{0}</p>]]></string>

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

@@ -1595,6 +1595,7 @@
 	<string name="_adm_stg_cpt_option_sys_session_lifetime_in_min"><![CDATA[Время жизни сессии (в минутах)]]></string>
 	<string name="_adm_stg_cpt_option_sys_default_curl_timeout"><![CDATA[cURL - Таймаут по умолчанию]]></string>
     <string name="_adm_stg_cpt_option_sys_ssl_allow_untrusted"><![CDATA[cURL - доверять неподписанным сертификатам или неподтвержденным хостам]]></string>
+    <string name="_adm_stg_cpt_option_sys_csp_frame_ancestors"><![CDATA[Значение заголовка 'Content-Security-Policy: frame-ancestors']]></string>
 	<string name="_adm_stg_cpt_option_template"><![CDATA[Основная тема]]></string>
 	<string name="_adm_stg_err_option_template"><![CDATA[Тема не может быть пустой и должна иметь приемлемое название.]]></string>
     <string name="_adm_stg_cpt_option_use_like_operator"><![CDATA[Использовать для поиска оператор LIKE (рекомендуется для небольшого содержимого)]]></string>
@@ -3409,6 +3410,10 @@
         <string name="_sys_txt_user_n"><![CDATA[Пользователь #{0}]]></string>
         <string name="_sys_txt_reports_title"><![CDATA[Жалобы]]></string>
         <string name="_sys_txt_reports_grid_view_notes"><![CDATA[Посмотреть заметки]]></string>
+        <string name="_sys_txt_share_popup_header"><![CDATA[Поделиться]]></string>
+        <string name="_sys_txt_share_popup_url"><![CDATA[URL]]></string>
+        <string name="_sys_txt_share_popup_copy_to_clipboard_text"><![CDATA[Кликните чтобы скопировать]]></string>
+        <string name="_sys_txt_share_popup_embeded_code"><![CDATA[Код для вставки]]></string>
         <string name="_sys_unconfirmed"><![CDATA[Неподтвержденный]]></string>
 	<string name="_sys_upgrade_conclusion"><![CDATA[<h3>Важная информация:</h3><p>{0}</p>]]></string>
 	<string name="_sys_upgrade_db_and_files_versions_different"><![CDATA[База данных и версии файлов отличаются, возможно, предыдущий патч не был правильно применён.]]></string>

+ 5 - 3
template/designbox_share_popup.html

@@ -1,13 +1,15 @@
 <div class="bx-db-share-popup">
     <div class="bx-db-share-popup-cnt">
-         <bx_menu:sys_social_sharing />
+         <div class="bx-def-margin-sec-bottom">
+             <bx_menu:sys_social_sharing />
+         </div>
          <div class="bx-def-margin-sec-bottom">
              <bx_text:_sys_txt_share_popup_url />       
-             <div class="bx-def-border bx-def-padding-sec rounded bx-def-font-small">__url__</div>
+             <div class="bx-def-border bx-def-padding-sec rounded bx-def-font-small" onClick="bx_copy_to_clipboard('__url__')" title="<bx_text:_sys_txt_share_popup_copy_to_clipboard_text />">__url__</div>
          </div>
          <div class="bx-def-margin-sec-bottom">
              <bx_text:_sys_txt_share_popup_embeded_code />        
-             <div class="bx-def-border bx-def-padding-sec rounded bx-def-font-small">__code__</div> 
+             <div class="bx-def-border bx-def-padding-sec rounded bx-def-font-small" onClick="bx_copy_to_clipboard('__code__')" title="<bx_text:_sys_txt_share_popup_copy_to_clipboard_text />">__code__</div> 
          </div>
     </div>
 </div>

+ 1 - 1
template/embed.html

@@ -1 +1 @@
-<iframe width="100%" height="300" src="__url__" title="__title__" frameborder="0" allowfullscreen></iframe>
+<iframe width="300" height="300" src="__url__" frameborder="0" allowfullscreen></iframe>

+ 4 - 3
template/scripts/BxBasePage.php

@@ -75,13 +75,14 @@ class BxBasePage extends BxDolPage
     public function performActionEmbed ()
     {
         $aCover = $this->getPageCoverImage();
+        $sTitle = $this->_getPageTitle();
         $this->_oTemplate->getEmbed($this->_oTemplate->parseHtmlByName('embed_card.html', [
-            'title' => _t($this->_aObject['title']),
+            'title' => $sTitle,
             'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
             'bx_if:thumb' => [
                 'condition' => $this->isPageCover() && count($aCover) > 0,
                 'content' => [
-                    'title' => _t($this->_aObject['title']),
+                    'title' => $sTitle,
                     'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
                     'background' => BxDolCover::getInstance(BxDolTemplate::getInstance())->getCoverImageUrl($aCover)
                 ],
@@ -89,7 +90,7 @@ class BxBasePage extends BxDolPage
             'bx_if:no_thumb' => [
                 'condition' => count($aCover) == 0 || !$this->isPageCover(),
                 'content' => [
-                    'title' => _t($this->_aObject['title']),
+                    'title' => $sTitle,
                     'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
                 ]
             ]