diff --git a/composer.json b/composer.json index f6d9020945..7a270cf234 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,7 @@ "vimeo/vimeo-api": "^3.0", "phpseclib/phpseclib": "^3.0", "bunnycdn/storage": "^3.0", - "chillerlan/php-qrcode": "^5.0" + "chillerlan/php-qrcode": "^5.0", + "erusev/parsedown": "^1.7" } } diff --git a/composer.lock b/composer.lock index d6b7ca1f90..ba21dc2e90 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d533d634209cdb9c65482b398f123942", + "content-hash": "22871f414bd488b32e41ae64c4ac12e2", "packages": [ { "name": "abraham/twitteroauth", @@ -987,6 +987,56 @@ "abandoned": true, "time": "2019-02-15T01:32:20+00:00" }, + { + "name": "erusev/parsedown", + "version": "1.7.4", + "source": { + "type": "git", + "url": "https://github.com/erusev/parsedown.git", + "reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/cb17b6477dfff935958ba01325f2e8a2bfa6dab3", + "reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35" + }, + "type": "library", + "autoload": { + "psr-0": { + "Parsedown": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "description": "Parser for Markdown.", + "homepage": "http://parsedown.org", + "keywords": [ + "markdown", + "parser" + ], + "support": { + "issues": "https://github.com/erusev/parsedown/issues", + "source": "https://github.com/erusev/parsedown/tree/1.7.x" + }, + "time": "2019-12-30T22:54:17+00:00" + }, { "name": "evenement/evenement", "version": "v3.0.2", @@ -6219,5 +6269,5 @@ "platform-overrides": { "php": "8" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/objects/comment.php b/objects/comment.php index 9d0d95fbb7..4c58b1dcdd 100644 --- a/objects/comment.php +++ b/objects/comment.php @@ -240,7 +240,7 @@ class Comment { $row = cleanUpRowFromDatabase($row); $row['comment'] = str_replace('\n', "\n", $row['comment']); $row['commentPlain'] = xss_esc_back($row['comment']); - $row['commentHTML'] = nl2br($row['commentPlain']); + $row['commentHTML'] = markDownToHTML($row['commentPlain']); $row['responses'] = array(); if($includeResponses){ $row['responses'] = self::getAllComments($videoId, $row['id'], $video_owner_users_id, $includeResponses); @@ -412,7 +412,7 @@ class Comment { if(empty($row['commentHTML'])){ $row['comment'] = str_replace('\n', "\n", $row['comment']); $row['commentPlain'] = xss_esc_back($row['comment']); - $row['commentHTML'] = nl2br($row['commentPlain']); + $row['commentHTML'] = markDownToHTML($row['commentPlain']); } $row['identification'] = User::getNameIdentificationById($row['users_id']); diff --git a/objects/functionsSecurity.php b/objects/functionsSecurity.php index acdbf101f9..49e3a87922 100644 --- a/objects/functionsSecurity.php +++ b/objects/functionsSecurity.php @@ -134,7 +134,7 @@ function requestComesFromSafePlace() /** * for security clean all non secure files from directory * @param string $dir - * @param string $allowedExtensions + * @param array $allowedExtensions * @return string */ function cleanDirectory($dir, $allowedExtensions = ['key', 'm3u8', 'ts', 'vtt', 'jpg', 'gif', 'mp3', 'webm', 'webp']) @@ -288,3 +288,29 @@ function isBot($returnTrueIfNoUserAgent=true) } return $_isBot; } + +function markDownToHTML($text) { + $parsedown = new Parsedown(); + + // Convert Markdown to HTML + $html = $parsedown->text($text); + + // Convert new lines to
tags + $html = nl2br($html); + + // Convert URLs to clickable links with target="_blank" + $html = preg_replace( + '/\b[^"\']https?:\/\/[^\s<]+/i', + '$0', + $html + ); + + // Add classes to images + $html = preg_replace( + '/]+)>/i', + '', + $html + ); + + return $html; +} diff --git a/plugin/Gallery/Gallery.php b/plugin/Gallery/Gallery.php index 5583d593e4..16b8c353ad 100644 --- a/plugin/Gallery/Gallery.php +++ b/plugin/Gallery/Gallery.php @@ -73,6 +73,7 @@ class Gallery extends PluginAbstract $obj->MainContainerFluid = true; $obj->hidePrivateVideos = false; $obj->BigVideo = true; + $obj->showLivesAboveBigVideo = false; diff --git a/plugin/Gallery/view/mainArea.php b/plugin/Gallery/view/mainArea.php index 0a7cd80e61..316911c72e 100644 --- a/plugin/Gallery/view/mainArea.php +++ b/plugin/Gallery/view/mainArea.php @@ -1,4 +1,7 @@ @@ -37,6 +40,9 @@ saveRequestVars(); } } if (empty($_GET['search']) && !isInfiniteScroll()) { + if ($obj->showLivesAboveBigVideo) { + include $global['systemRootPath'] . 'plugin/Gallery/view/mainAreaLiveRow.php'; + } include $global['systemRootPath'] . 'plugin/Gallery/view/BigVideoLive.php'; } //var_dump(!empty($video), debug_backtrace());exit; @@ -48,24 +54,9 @@ saveRequestVars(); include $global['systemRootPath'] . 'plugin/Gallery/view/BigVideo.php'; } echo '
' . getAdsLeaderBoardTop2() . '
'; - if (empty($_REQUEST['catName'])) { - $objLive = AVideoPlugin::getDataObject('Live'); - if (empty($objLive->doNotShowLiveOnVideosList)) { - ?> - - - - - -
- +