Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43294
Total Topics: 7523
Most Online Today: 118
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 117
Total: 118

Author Topic: fatal_error showing html as plain text  (Read 6505 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
fatal_error showing html as plain text
« on: September 30, 2016, 11:46:31 am »
This is frustrating, I'm trying to add a bit of html to my ban message, but it's displaying all html tags as plain text.

For example:

Code: [Select]
// You banned, sucka!

$ban_text = '<div>'.sprintf($txt[430], $old_name).'</div>';

if(!empty($_SESSION['ban']['cannot_access']['reason']))
$ban_text .= '<div>'.$txt['your_ban_reason'].' '.$_SESSION['ban']['cannot_access']['reason'].'</div>';

if(!empty($_SESSION['ban']['expire_time']))
$ban_text .= '<div>'.sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)).'<div>';
else
$ban_text .= '<div>'.$txt['your_ban_expires_never'].'</div>';


fatal_error($ban_text, 'user');

Shows as:

<div>Sorry MSDos, you are banned from using this forum.</div><div>Reason: ...</div><div>Expiration: Your ban is not set to expire.</div> 


In the browser. So, what should I do to render the <div>'s?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16451
    • View Profile
Re: fatal_error showing html as plain text
« Reply #1 on: September 30, 2016, 11:54:03 am »
You would probably need to modify the function fatal_error

htmlspecialchars is used to protect from security issues from errors
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: fatal_error showing html as plain text
« Reply #2 on: September 30, 2016, 12:07:46 pm »
Right, but looking at fatal_error in Errors.php,

htmlspecialchars is not found :-\

Code: [Select]
// An irrecoverable error.
function fatal_error($error, $log = true)
{
global $txt, $context, $modSettings;

// We don't have $txt yet, but that's okay...
if (empty($txt))
die($error);

// TinyPortal
if(!isset($context['tp_prefix']))
TPortal_init();
// end

// Log the error and set up the template.
if (!isset($context['error_title']))
{
$context['error_title'] = $txt[106];
$context['error_message'] = $log || (!empty($modSettings['enableErrorLogging']) && $modSettings['enableErrorLogging'] == 2) ? log_error($error) : $error;
}

// If there's not a page title yet, set one.
if (!isset($context['page_title']))
$context['page_title'] = $context['error_title'];

// Display the error message - wireless?
if (WIRELESS)
$context['sub_template'] = WIRELESS_PROTOCOL . '_error';

// Load the template and set the sub template.
else
{
loadTemplate('Errors');
$context['sub_template'] = 'fatal_error';
}

// We want whatever for the header, and a footer. (footer includes sub template!)
obExit(null, true);

/* DO NOT IGNORE:
If you are creating a bridge to SMF or modifying this function, you MUST
make ABSOLUTELY SURE that this function quits and DOES NOT RETURN TO NORMAL
PROGRAM FLOW.  Otherwise, security error messages will not be shown, and
your forum will be in a very easily hackable state.
*/
trigger_error('Hacking attempt...', E_USER_ERROR);
}

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16451
    • View Profile
Re: fatal_error showing html as plain text
« Reply #3 on: September 30, 2016, 12:10:24 pm »
Then it would be part of function  log_error(
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: fatal_error showing html as plain text
« Reply #4 on: September 30, 2016, 12:15:34 pm »
You were right, I added htmlspecialchars_decode into the errors.template.php to do the opposite of it.

 

Related Topics

  Subject / Started by Replies Last post
HTML??

Started by Riley Support

1 Replies
5388 Views
Last post October 30, 2010, 10:43:27 am
by earthond
2 Replies
6693 Views
Last post March 14, 2009, 03:31:14 pm
by spiritanointed
1 Replies
6588 Views
Last post August 25, 2009, 08:04:21 pm
by SMFHacks
1 Replies
3355 Views
Last post May 15, 2010, 08:55:37 pm
by SMFHacks
1 Replies
4146 Views
Last post August 14, 2015, 10:19:21 am
by Labradoodle-360

+- Recent Topics

Please Help! by fmofmpls
Today at 01:47:09 pm

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

Powered by EzPortal