Vergleich inc/class_error.php - 1.8.20 - 1.8.27

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 116Zeile 116
	 * @var boolean
*/
public $has_errors = false;

	 * @var boolean
*/
public $has_errors = false;

 

/**
* Display errors regardless of related settings (useful during initialization stage)
*
* @var boolean
*/
public $force_display_errors = false;


/**
* Initializes the error handler


/**
* Initializes the error handler

Zeile 140Zeile 147
	 * @param string $message The error message
* @param string $file The error file
* @param integer $line The error line

	 * @param string $message The error message
* @param string $file The error file
* @param integer $line The error line

 
	 * @param boolean $allow_output Whether or not output is permitted

	 * @return boolean True if parsing was a success, otherwise assume a error
*/

	 * @return boolean True if parsing was a success, otherwise assume a error
*/

	function error($type, $message, $file=null, $line=0)

	function error($type, $message, $file=null, $line=0, $allow_output=true)

	{
global $mybb;


	{
global $mybb;


Zeile 152Zeile 160
			return true;
}


			return true;
}


		if(in_array($type, $this->ignore_types))
{
return true;
}

$file = str_replace(MYBB_ROOT, "", $file);

		if(in_array($type, $this->ignore_types))
{
return true;
}

$file = str_replace(MYBB_ROOT, "", $file);


$this->has_errors = true;



$this->has_errors = true;


Zeile 165Zeile 173
		$accepted_error_types = array('both', 'error', 'warning', 'none');
if(!in_array($mybb->settings['errortypemedium'], $accepted_error_types))
{

		$accepted_error_types = array('both', 'error', 'warning', 'none');
if(!in_array($mybb->settings['errortypemedium'], $accepted_error_types))
{

			$mybb->settings['errortypemedium'] = "both";

			$mybb->settings['errortypemedium'] = "none";

		}

if(defined("IN_TASK"))

		}

if(defined("IN_TASK"))

Zeile 181Zeile 189
			}

add_task_log($task, "{$this->error_types[$type]} - [$type] ".var_export($message, true)."{$filestr}");

			}

add_task_log($task, "{$this->error_types[$type]} - [$type] ".var_export($message, true)."{$filestr}");

		}

		}


// Saving error to log file.
if($mybb->settings['errorlogmedium'] == "log" || $mybb->settings['errorlogmedium'] == "both")


// Saving error to log file.
if($mybb->settings['errorlogmedium'] == "log" || $mybb->settings['errorlogmedium'] == "both")

		{

		{

			$this->log_error($type, $message, $file, $line);
}


			$this->log_error($type, $message, $file, $line);
}


Zeile 195Zeile 203
			$this->email_error($type, $message, $file, $line);
}


			$this->email_error($type, $message, $file, $line);
}


		// SQL Error
if($type == MYBB_SQL)

		if($allow_output === true)


		{

		{

			$this->output_error($type, $message, $file, $line);
}
else
{
// Do we have a PHP error?
if(my_strpos(my_strtolower($this->error_types[$type]), 'warning') === false)

			// SQL Error
if($type == MYBB_SQL)





			{
$this->output_error($type, $message, $file, $line);
}

			{
$this->output_error($type, $message, $file, $line);
}

			// PHP Error

 
			else
{

			else
{

				if($mybb->settings['errortypemedium'] == "none" || $mybb->settings['errortypemedium'] == "error")
{
echo "<div class=\"php_warning\">MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.</div>";


				// Do we have a PHP error?
if(my_strpos(my_strtolower($this->error_types[$type]), 'warning') === false)
{
$this->output_error($type, $message, $file, $line);

				}

				}

 
				// PHP Error

				else
{

				else
{

					global $templates;

$warning = "<strong>{$this->error_types[$type]}</strong> [$type] $message - Line: $line - File: $file PHP ".PHP_VERSION." (".PHP_OS.")<br />\n";
if(is_object($templates) && method_exists($templates, "get") && !defined("IN_ADMINCP"))

					if($mybb->settings['errortypemedium'] == "none" || $mybb->settings['errortypemedium'] == "error")




					{

					{

						$this->warnings .= $warning;
$this->warnings .= $this->generate_backtrace();

						echo "<div class=\"php_warning\">MyBB Internal: One or more warnings occurred. Please contact your administrator for assistance.</div>";


					}
else
{

					}
else
{

						echo "<div class=\"php_warning\">{$warning}".$this->generate_backtrace()."</div>";












						global $templates;

$warning = "<strong>{$this->error_types[$type]}</strong> [$type] $message - Line: $line - File: $file PHP ".PHP_VERSION." (".PHP_OS.")<br />\n";
if(is_object($templates) && method_exists($templates, "get") && !defined("IN_ADMINCP"))
{
$this->warnings .= $warning;
$this->warnings .= $this->generate_backtrace();
}
else
{
echo "<div class=\"php_warning\">{$warning}".$this->generate_backtrace()."</div>";
}

					}
}
}

					}
}
}

Zeile 313Zeile 324

/**
* Logs the error in the specified error log file.


/**
* Logs the error in the specified error log file.

	 *
* @param string $type Warning type
* @param string $message Warning message
* @param string $file Warning file

	 *
* @param string $type Warning type
* @param string $message Warning message
* @param string $file Warning file

	 * @param integer $line Warning line
*/
function log_error($type, $message, $file, $line)
{
global $mybb;

	 * @param integer $line Warning line
*/
function log_error($type, $message, $file, $line)
{
global $mybb;





		if($type == MYBB_SQL)
{
$message = "SQL Error: {$message['error_no']} - {$message['error']}\nQuery: {$message['query']}";

		if($type == MYBB_SQL)
{
$message = "SQL Error: {$message['error_no']} - {$message['error']}\nQuery: {$message['query']}";

		}


		}


		// Do not log something that might be executable
$message = str_replace('<?', '< ?', $message);


		// Do not log something that might be executable
$message = str_replace('<?', '< ?', $message);


		if(function_exists('debug_backtrace'))
{
ob_start();
debug_print_backtrace();
$trace = ob_get_contents();
ob_end_clean();

$back_trace = "\t<back_trace>{$trace}</back_trace>\n";
}
else

		$back_trace = $this->generate_backtrace(false, 2);

if($back_trace)








		{

		{

			$back_trace = '';

			$back_trace = "\t<back_trace>{$back_trace}</back_trace>\n";

		}

$error_data = "<error>\n";

		}

$error_data = "<error>\n";

Zeile 423Zeile 427
		{
$mybb->settings['bbname'] = "MyBB";
}

		{
$mybb->settings['bbname'] = "MyBB";
}



		

		if($type == MYBB_SQL)
{
$title = "MyBB SQL Error";
$error_message = "<p>MyBB has experienced an internal SQL error and cannot continue.</p>";

		if($type == MYBB_SQL)
{
$title = "MyBB SQL Error";
$error_message = "<p>MyBB has experienced an internal SQL error and cannot continue.</p>";

			if($mybb->settings['errortypemedium'] == "both" || $mybb->settings['errortypemedium'] == "error" || defined("IN_INSTALL") || defined("IN_UPGRADE"))

			if($this->force_display_errors || $mybb->settings['errortypemedium'] == "both" || $mybb->settings['errortypemedium'] == "error" || defined("IN_INSTALL") || defined("IN_UPGRADE"))

			{
$message['query'] = htmlspecialchars_uni($message['query']);
$message['error'] = htmlspecialchars_uni($message['error']);

			{
$message['query'] = htmlspecialchars_uni($message['query']);
$message['error'] = htmlspecialchars_uni($message['error']);

Zeile 437Zeile 441
				if($message['query'] != "")
{
$error_message .= "<dt>Query:</dt>\n<dd>{$message['query']}</dd>\n";

				if($message['query'] != "")
{
$error_message .= "<dt>Query:</dt>\n<dd>{$message['query']}</dd>\n";

				}
$error_message .= "</dl>\n";
}
}
else

				}
$error_message .= "</dl>\n";
}
}
else

		{
$title = "MyBB Internal Error";
$error_message = "<p>MyBB has experienced an internal error and cannot continue.</p>";

		{
$title = "MyBB Internal Error";
$error_message = "<p>MyBB has experienced an internal error and cannot continue.</p>";

			if($mybb->settings['errortypemedium'] == "both" || $mybb->settings['errortypemedium'] == "error" || defined("IN_INSTALL") || defined("IN_UPGRADE"))

			if($this->force_display_errors || $mybb->settings['errortypemedium'] == "both" || $mybb->settings['errortypemedium'] == "error" || defined("IN_INSTALL") || defined("IN_UPGRADE"))

			{
$error_message .= "<dl>\n";
$error_message .= "<dt>Error Type:</dt>\n<dd>{$this->error_types[$type]} ($type)</dd>\n";

			{
$error_message .= "<dl>\n";
$error_message .= "<dt>Error Type:</dt>\n<dd>{$this->error_types[$type]} ($type)</dd>\n";

Zeile 458Zeile 462
						$code_pre = @file($file);

$code = "";

						$code_pre = @file($file);

$code = "";





						if(isset($code_pre[$line-4]))
{
$code .= $line-3 . ". ".$code_pre[$line-4];
}

if(isset($code_pre[$line-3]))

						if(isset($code_pre[$line-4]))
{
$code .= $line-3 . ". ".$code_pre[$line-4];
}

if(isset($code_pre[$line-3]))

						{

						{

							$code .= $line-2 . ". ".$code_pre[$line-3];

							$code .= $line-2 . ". ".$code_pre[$line-3];

						}


						}


						if(isset($code_pre[$line-2]))
{
$code .= $line-1 . ". ".$code_pre[$line-2];

						if(isset($code_pre[$line-2]))
{
$code .= $line-1 . ". ".$code_pre[$line-2];

						}


						}


						$code .= $line . ". ".$code_pre[$line-1]; // The actual line.

if(isset($code_pre[$line]))

						$code .= $line . ". ".$code_pre[$line-1]; // The actual line.

if(isset($code_pre[$line]))

Zeile 503Zeile 507
								$parser = new postParser;
$parser_exists = true;
}

								$parser = new postParser;
$parser_exists = true;
}

						}

						}

						else
{
$parser_exists = true;

						else
{
$parser_exists = true;

						}


						}


						if($parser_exists)
{
$code = $parser->mycode_parse_php($code, true);

						if($parser_exists)
{
$code = $parser->mycode_parse_php($code, true);

						}

						}

						else
{
$code = @nl2br($code);

						else
{
$code = @nl2br($code);

Zeile 520Zeile 524

$error_message .= "<dt>Code:</dt><dd>{$code}</dd>\n";
}


$error_message .= "<dt>Code:</dt><dd>{$code}</dd>\n";
}

				}

				}

				$backtrace = $this->generate_backtrace();
if($backtrace && !in_array($type, $this->mybb_error_types))
{
$error_message .= "<dt>Backtrace:</dt><dd>{$backtrace}</dd>\n";
}
$error_message .= "</dl>\n";

				$backtrace = $this->generate_backtrace();
if($backtrace && !in_array($type, $this->mybb_error_types))
{
$error_message .= "<dt>Backtrace:</dt><dd>{$backtrace}</dd>\n";
}
$error_message .= "</dl>\n";

			}
}


			}
}


		if(isset($lang->settings['charset']))
{
$charset = $lang->settings['charset'];

		if(isset($lang->settings['charset']))
{
$charset = $lang->settings['charset'];

		}

		}

		else

		else

		{

		{

			$charset = 'UTF-8';
}

			$charset = 'UTF-8';
}

 

$contact_site_owner = '';
$is_in_contact = defined('THIS_SCRIPT') && THIS_SCRIPT === 'contact.php';
if(!$is_in_contact && ($mybb->settings['contactlink'] == "contact.php" && $mybb->settings['contact'] == 1 && ($mybb->settings['contact_guests'] != 1 && $mybb->user['uid'] == 0 || $mybb->user['uid'] > 0)) || $mybb->settings['contactlink'] != "contact.php")
{
if(!my_validate_url($mybb->settings['contactlink'], true, true) && my_substr($mybb->settings['contactlink'], 0, 7) != 'mailto:')
{
$mybb->settings['contactlink'] = $mybb->settings['bburl'].'/'.$mybb->settings['contactlink'];
}

$contact_site_owner = <<<HTML
If this problem persists, please <a href="{$mybb->settings['contactlink']}">contact the site owner</a>.
HTML;
}

$additional_name = '';
$docs_link = 'https://docs.mybb.com';
$common_issues_link = 'https://docs.mybb.com/1.8/faq/';
$support_link = 'https://community.mybb.com/';

if(isset($lang->settings['docs_link']))
{
$docs_link = $lang->settings['docs_link'];
}

if(isset($lang->settings['common_issues_link']))
{
$common_issues_link = $lang->settings['common_issues_link'];
}

if(isset($lang->settings['support_link']))
{
$support_link = $lang->settings['support_link'];
}


if(isset($lang->settings['additional_name']))
{
$additional_name = $lang->settings['additional_name'];
}

$contact = <<<HTML
<p>
<strong>If you're a visitor of this website</strong>, please wait a few minutes and try again.{$contact_site_owner}
</p>

<p>
<strong>If you are the site owner</strong>, please check the <a href="{$docs_link}">MyBB{$additional_name} Documentation</a> for help resolving <a href="{$common_issues_link}">common issues</a>, or get technical help on the <a href="{$support_link}">MyBB{$additional_name} Community Forums</a>.
</p>
HTML;


if(!headers_sent() && !defined("IN_INSTALL") && !defined("IN_UPGRADE"))
{


if(!headers_sent() && !defined("IN_INSTALL") && !defined("IN_UPGRADE"))
{

Zeile 579Zeile 633

<div id="error">
{$error_message}


<div id="error">
{$error_message}

				<p id="footer">Please contact the <a href="https://mybb.com">MyBB Group</a> for technical support.</p>

				<p id="footer">{$contact}</p>

			</div>
</div>
</div>

			</div>
</div>
</div>

Zeile 604Zeile 658
		<h2>{$title}</h2>
<div id="mybb_error_error">
{$error_message}

		<h2>{$title}</h2>
<div id="mybb_error_error">
{$error_message}

			<p id="mybb_error_footer">Please contact the <a href="https://mybb.com">MyBB Group</a> for technical support.</p>

			<p id="mybb_error_footer">{$contact}</p>

		</div>
</div>
EOF;
}

		</div>
</div>
EOF;
}

 


		exit(1);
}

		exit(1);
}





	/**
* Generates a backtrace if the server supports it.
*
* @return string The generated backtrace
*/

	/**
* Generates a backtrace if the server supports it.
*
* @return string The generated backtrace
*/

	function generate_backtrace()

	function generate_backtrace($html=true, $strip=1)

	{
$backtrace = '';
if(function_exists("debug_backtrace"))
{

	{
$backtrace = '';
if(function_exists("debug_backtrace"))
{

			$trace = debug_backtrace();
$backtrace = "<table style=\"width: 100%; margin: 10px 0; border: 1px solid #aaa; border-collapse: collapse; border-bottom: 0;\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
$backtrace .= "<thead><tr>\n";
$backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">File</th>\n";
$backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">Line</th>\n";
$backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">Function</th>\n";
$backtrace .= "</tr></thead>\n<tbody>\n";

			$trace = debug_backtrace(1<<1 /* DEBUG_BACKTRACE_IGNORE_ARGS */);











			// Strip off this function from trace
array_shift($trace);













			if($html)
{
$backtrace = "<table style=\"width: 100%; margin: 10px 0; border: 1px solid #aaa; border-collapse: collapse; border-bottom: 0;\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
$backtrace .= "<thead><tr>\n";
$backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">File</th>\n";
$backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">Line</th>\n";
$backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">Function</th>\n";
$backtrace .= "</tr></thead>\n<tbody>\n";
}

// Strip off calls from trace
$trace = array_slice($trace, $strip);

$i = 0;


foreach($trace as $call)
{
if(empty($call['file'])) $call['file'] = "[PHP]";


foreach($trace as $call)
{
if(empty($call['file'])) $call['file'] = "[PHP]";

				if(empty($call['line'])) $call['line'] = "&nbsp;";

				if(empty($call['line'])) $call['line'] = " ";

				if(!empty($call['class'])) $call['function'] = $call['class'].$call['type'].$call['function'];
$call['file'] = str_replace(MYBB_ROOT, "/", $call['file']);

				if(!empty($call['class'])) $call['function'] = $call['class'].$call['type'].$call['function'];
$call['file'] = str_replace(MYBB_ROOT, "/", $call['file']);

				$backtrace .= "<tr>\n";
$backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['file']}</td>\n";
$backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['line']}</td>\n";
$backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['function']}</td>\n";
$backtrace .= "</tr>\n";

















if($html)
{
$backtrace .= "<tr>\n";
$backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['file']}</td>\n";
$backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['line']}</td>\n";
$backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['function']}</td>\n";
$backtrace .= "</tr>\n";
}
else
{
$backtrace .= "#{$i} {$call['function']}() called at [{$call['file']}:{$call['line']}]\n";
}

$i++;
}

if($html)
{
$backtrace .= "</tbody></table>\n";

			}

			}

			$backtrace .= "</tbody></table>\n";

 
		}
return $backtrace;
}

		}
return $backtrace;
}