Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Format Comment - Improved
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2023-01-21 03:00:50
A shorter and fully compatible solution to UTF-8 and ISO-8859-1 descriptions/titles.

This only allows BR tags, and removes all other HTML allowing line breaks in descriptions which preserves the text presentation.

Removed:
pulling swear words from database. Unnecessary overhead when we can just read a local array.


function format_comment(string $text): mixed
{
$censor = array('ass', 'shit');
if (strlen($text) > 0) {
$text = str_ireplace($censor, '(censored)', $text);
$text = mb_convert_encoding($text, 'UTF-8', 'ISO-8859-1');
$string = preg_replace('/\r\n|\r|\n/', '<br>', strtr($text, array_combine(array('', '', '', '', '', '', '[img]', '[/img]', '[img=', '[/img]'), array('<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<img src=', ' />', '<img src=', ' />'))), -1, $count);
if ($count === 0) {
$string = strip_tags($string, '<br>');
}
$smilies = array(':)' => 'smile.png', ':(' => 'sad.png', ';)' => 'wink.png', ':P' => 'razz.png', ':D' => 'grin.png', ':|' => 'plain.png', ':O' => 'suprise.png', ':?' => 'confused.png', '8)' => 'glasses.png', '8o' => 'eek.png', 'B)' => 'cool.png', ':-)' => 'smile-big.png', ':-(' => 'crying.png', ':-*' => 'kiss.png', 'O:-D' => 'angel.png', ':-@' => 'devilish.png', ':o)' => 'monkey.png', ':help' => 'help.png', ':love' => 'love.png', ':warn' => 'warn.png', ':bomb' => 'bomb.png', ':idea' => 'idea.png', ':bad' => 'bad.png', ':!' => 'important.png', 'brb' => 'brb.png');
foreach ($smilies as $code => &$url) {
$string = str_replace($code, '<img style="width:25px;height:25px;vertical-align:middle" src="/images/smilies/' . $url . '" alt="' . $code . '" title="' . $code . '" />', $string);
}
return $string;
}
return false;
}
Last edited by STorrents2020 on 2023-01-21 03:10:17
2023-01-21 08:52:20
I have two questions regarding comments and their format.
Is there a possibility that we avoid "images" and instead of gif/png implement flaticons or fontawesome? My opinion is that we have way too many images to implement on page load.
And the second question, if you quote any record, why is it impossible to have "line breaks" as in the original record?
Have tried to "figure it out" but haven't gotten very far on this front.

Otherwise, thanks for the MOD will test it soon


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2023-01-21 08:57:56
I think we can implement that no problem with a base set of compatible rendered characters


function format_comment(string $text): mixed
{
global $site_config;
$censor = $site_config['blacklist'];
...


'blacklist' => array('shit', 'poo', 'fckr');


I dont think you need a global, you can remove that
Last edited by STorrents2020 on 2023-01-21 09:02:20
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728