Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 202
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 169
Total: 169

Author Topic: fatal_error showing html as plain text  (Read 6483 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: 16436
    • 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: 16436
    • 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
5370 Views
Last post October 30, 2010, 10:43:27 am
by earthond
2 Replies
6683 Views
Last post March 14, 2009, 03:31:14 pm
by spiritanointed
1 Replies
6556 Views
Last post August 25, 2009, 08:04:21 pm
by SMFHacks
1 Replies
3340 Views
Last post May 15, 2010, 08:55:37 pm
by SMFHacks
1 Replies
4127 Views
Last post August 14, 2015, 10:19:21 am
by Labradoodle-360

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

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

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal