Skip to content

Improve error logging while in SSI #7789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: release-2.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Sources/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ function log_error($error_message, $error_type = 'general', $file = null, $line
$user_info['ip'] = '';

// Find the best query string we can...
$query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING'];
if (SMF === 'SSI')
$query_string = $_SERVER['REQUEST_URL'] ?? (($_SERVER['REQUEST_SCHEME'] ?? 'http') . '://' . ($_SERVER['SERVER_NAME'] ?? 'unknown') . '/' . ($_SERVER['REQUEST_URI'] ?? (($_SERVER['DOCUMENT_URI'] ?? $_SERVER['SCRIPT_NAME'] ?? 'unknown.php') . !empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')));
else
$query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING'];

// Don't log the session hash in the url twice, it's a waste.
if (!empty($smcFunc['htmlspecialchars']))
$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));

// Just so we know what board error messages are from.
if (isset($_POST['board']) && !isset($_GET['board']))
if (isset($_POST['board']) && !isset($_GET['board']) && SMF !== 'SSI')
$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];

// What types of categories do we have?
Expand Down
2 changes: 1 addition & 1 deletion Sources/ManageErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function ViewErrorLog()
'time' => timeformat($row['log_time']),
'timestamp' => $row['log_time'],
'url' => array(
'html' => $smcFunc['htmlspecialchars'](strpos($row['url'], 'cron.php') === false ? (substr($row['url'], 0, 1) == '?' ? $scripturl : '') . $row['url'] : $row['url']),
'html' => $smcFunc['htmlspecialchars'](strpos($row['url'], 'cron.php') === false && !(strpos($row['url'], 'https://') === 0) && !(strpos($row['url'], 'http://') === 0) ? ($row['url'][0] == '?' ? $scripturl : '') . $row['url'] : $row['url']),
'href' => base64_encode($smcFunc['db_escape_wildcard_string']($row['url']))
),
'message' => array(
Expand Down