Used br2nl() in ajax alert messages (#1106)

This commit is contained in:
Roman Kelesidis 2023-11-15 21:49:51 +07:00 committed by GitHub
commit b82c19719c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View file

@ -21,7 +21,7 @@ $bb_cfg = [];
$bb_cfg['js_ver'] = $bb_cfg['css_ver'] = 1;
// Version info
$bb_cfg['tp_version'] = 'v2.4.0-beta4';
$bb_cfg['tp_version'] = 'v2.4.0-rc1';
$bb_cfg['tp_release_date'] = '14-11-2023';
$bb_cfg['tp_release_codename'] = 'Cattle';
@ -91,7 +91,7 @@ $bb_cfg['server_port'] = !empty($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT
$bb_cfg['script_path'] = '/'; // The path where FORUM is located relative to the domain name
// GZip
$bb_cfg['gzip_compress'] = false; // compress output
$bb_cfg['gzip_compress'] = false; // Compress output
// Tracker
$bb_cfg['announce_interval'] = 1800; // Announce interval (default: 1800)
@ -138,10 +138,10 @@ $bb_cfg['dl_complete_days_keep'] = 180;
$bb_cfg['dl_cancel_days_keep'] = 30;
// Tor-Stats
$bb_cfg['torstat_days_keep'] = 60; // days to keep user's per-torrent stats
$bb_cfg['torstat_days_keep'] = 60; // Days to keep user's per-torrent stats
// Tor-Help
$bb_cfg['torhelp_enabled'] = false; // find dead torrents (without seeder) that user might help seeding
$bb_cfg['torhelp_enabled'] = false; // Find dead torrents (without seeder) that user might help seeding
// URL's
$bb_cfg['ajax_url'] = 'ajax.php'; # "http://{$_SERVER['SERVER_NAME']}/ajax.php"

View file

@ -321,6 +321,17 @@ function send_no_cache_headers()
header('Pragma: no-cache');
}
/**
* Converts "<br>" tags to "\n" line breaks
*
* @param string $string
* @return string
*/
function br2nl(string $string): string
{
return preg_replace('#<br\s*/?>#i', "\n", $string);
}
/**
* Adds commas between every group of thousands
*

View file

@ -145,7 +145,7 @@ class Ajax
public function ajax_die(string $error_msg, int $error_code = E_AJAX_GENERAL_ERROR): void
{
$this->response['error_code'] = $error_code;
$this->response['error_msg'] = strip_tags($error_msg);
$this->response['error_msg'] = strip_tags(br2nl($error_msg));
// Get caller info
if (!empty($_COOKIE['explain'])) {
@ -258,7 +258,7 @@ class Ajax
}
$this->response['prompt_confirm'] = 1;
$this->response['confirm_msg'] = strip_tags($confirm_msg);
$this->response['confirm_msg'] = strip_tags(br2nl($confirm_msg));
$this->send();
}