diff --git a/htdocs/class/textsanitizer/flash/config.flash.dist.php b/htdocs/class/textsanitizer/flash/config.flash.dist.php deleted file mode 100644 index 9e9de4cf3..000000000 --- a/htdocs/class/textsanitizer/flash/config.flash.dist.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -defined('XOOPS_ROOT_PATH') || exit('Restricted access'); - -return $config = array( - 'detect_dimension' => 1, - 'enable_flash_entry' => false, // false to disable entry button in editor, existing content will still play -); diff --git a/htdocs/class/textsanitizer/flash/flash.php b/htdocs/class/textsanitizer/flash/flash.php deleted file mode 100644 index e547b417b..000000000 --- a/htdocs/class/textsanitizer/flash/flash.php +++ /dev/null @@ -1,127 +0,0 @@ - - */ -defined('XOOPS_ROOT_PATH') || exit('Restricted access'); - -/** - * Class MytsFlash - */ -class MytsFlash extends MyTextSanitizerExtension -{ - /** - * @param $textarea_id - * - * @return array - */ - public function encode($textarea_id) - { - $config = parent::loadConfig(__DIR__); - if ($config['enable_flash_entry'] === false) { - return array(); - } - $code = ""; - $javascript = << 0) { - var text = selection; - } else { - var text = prompt(enterFlashPhrase, ""); - } - var domobj = xoopsGetElementById(id); - if (text.length > 0) { - var text2 = enableDimensionDetect ? "" : prompt(enterFlashWidthPhrase, ""); - var text3 = enableDimensionDetect ? "" : prompt(enterFlashHeightPhrase, ""); - var result = "[flash="+text2+","+text3+"]" + text + "[/flash]"; - xoopsInsertText(domobj, result); - } - domobj.focus(); - } -EOF; - - return array( - $code, - $javascript); - } - - /** - * @param $match - * - * @return string - */ - public static function myCallback($match) - { - return self::decode($match[5], $match[3], $match[4]); - } - - /** - * @param MyTextSanitizer $myts - * - * @return bool - */ - public function load(MyTextSanitizer $myts) - { - $myts->callbackPatterns[] = "/\[(swf|flash)=(['\"]?)([^\"']*),([^\"']*)\\2]([^\"]*)\[\/\\1\]/sU"; - $myts->callbacks[] = __CLASS__ . '::myCallback'; - - return true; - } - - /** - * @param $url - * @param $width - * @param $height - * - * @return string - */ - public static function decode($url, $width, $height) - { - $config = parent::loadConfig(__DIR__); - - if ((empty($width) || empty($height)) && !empty($config['detect_dimension'])) { - if (!$dimension = @getimagesize($url)) { - return "{$url}"; - } - if (!empty($width)) { - $height = $dimension[1] * $width / $dimension[0]; - } elseif (!empty($height)) { - $width = $dimension[0] * $height / $dimension[1]; - } else { - list($width, $height) = array( - $dimension[0], - $dimension[1]); - } - } - - $rp = ""; - $rp .= ""; - $rp .= ""; - $rp .= ""; - $rp .= ""; - $rp .= ""; - $rp .= ''; - - return $rp; - } -} diff --git a/htdocs/class/textsanitizer/flash/index.php b/htdocs/class/textsanitizer/flash/index.php deleted file mode 100644 index 6a5054350..000000000 --- a/htdocs/class/textsanitizer/flash/index.php +++ /dev/null @@ -1,2 +0,0 @@ -"; + $buttonHtml = ""; $javascript = << 0) { - var text = selection; - } else { - var text = prompt(enterMp3Phrase, ""); - } - var domobj = xoopsGetElementById(id); - if (text.length > 0) { - var result = "[mp3]" + text + "[/mp3]"; - xoopsInsertText(domobj, result); - } - domobj.focus(); - } -EOF; - - return array( - $code, - $javascript); +function xoopsCodeMp3(id) { + var text = prompt("Enter MP3 URL (e.g., https://example.com/audio.mp3)", xoopsGetSelect(id)); + while (text !== null && !text.trim().match(/^https?:\/\/[\w\-\.]+(\:\d+)?\/.+\.mp3(\?.*)?$/i)) { + alert("Invalid MP3 URL. The URL must begin with http or https and end with .mp3"); + text = prompt("Enter MP3 URL (e.g., https://example.com/audio.mp3)", text); } + if (text && text.trim().length > 0) { + xoopsInsertText(document.getElementById(id), "[mp3]" + text.trim() + "[/mp3]"); + } +} +EOF; - /** - * @param $match - * - * @return string - */ - public static function myCallback($match) - { - return self::decode($match[1]); + return [$buttonHtml, $javascript]; } /** - * @param MyTextSanitizer $myts - * * @return bool */ public function load(MyTextSanitizer $myts) { - $myts->callbackPatterns[] = "/\[mp3\](.*?)\[\/mp3\]/s"; - $myts->callbacks[] = __CLASS__ . '::myCallback'; - + $myts->callbackPatterns[] = '/\[mp3\](.*?)\[\/mp3\]/s'; + $myts->callbacks[] = __CLASS__ . '::decode'; return true; } /** - * @param $url - * + * @param string|array $url + * @param string|int $width + * @param string|int $height * @return string */ - public static function decode($url, $width, $height) + public static function decode($url, $width = 0, $height = 0) { - $rp = ""; - - return $rp; + if (is_array($url)) { + $url = htmlspecialchars($url[1], ENT_QUOTES, 'UTF-8', false); // Prevent double-encoding + } else { + $url = htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false); // Prevent double-encoding + } + return ""; } }