mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 00:34:46 +02:00
Added html enconde
This commit is contained in:
parent
f7f81f5344
commit
f6f96523a0
@ -48,18 +48,16 @@ if (isset($config['homedir'])) {
|
|||||||
*/
|
*/
|
||||||
function ui_bbcode_to_html($text, $allowed_tags=['[url]'])
|
function ui_bbcode_to_html($text, $allowed_tags=['[url]'])
|
||||||
{
|
{
|
||||||
$return = io_safe_output($text);
|
|
||||||
|
|
||||||
if (array_search('[url]', $allowed_tags) !== false) {
|
if (array_search('[url]', $allowed_tags) !== false) {
|
||||||
// If link hasn't http, add it.
|
// If link hasn't http, add it.
|
||||||
if (preg_match('/https?:\/\//', $return)) {
|
if (preg_match('/https?:\/\//', $text)) {
|
||||||
$html_bbcode = '<a target="_blank" rel="noopener noreferrer" href="$1">$2</a>';
|
$html_bbcode = '<a target="_blank" rel="noopener noreferrer" href="$1">$2</a>';
|
||||||
} else {
|
} else {
|
||||||
$html_bbcode = '<a target="_blank" rel="noopener noreferrer" href="http://$1">$2</a>';
|
$html_bbcode = '<a target="_blank" rel="noopener noreferrer" href="http://$1">$2</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace bbcode format [url=www.example.org] String [/url] with or without http and slashes
|
// Replace bbcode format [url=www.example.org] String [/url] with or without http and slashes
|
||||||
$return = preg_replace('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $html_bbcode, $return);
|
$return = preg_replace('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $html_bbcode, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user