Commit c706e8ec authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4336 (Bootstrapping issue with hack-attacks on keep_lang parameter)

parent 5e370188
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1710,7 +1710,7 @@ class DatabaseConnector

        // Optimisation: Load language fields in advance so we don't need to do additional details when calling get_translated_* functions
        $lang_strings_expecting = array();
        if ($lang_fields !== null) {
        if (!empty($lang_fields)) {
            if (multi_lang_content()) {
                if ((strpos($query, 'text_original') !== false) || (function_exists('user_lang')) && ((is_null($start)) || ($start < 200))) {
                    $lang = function_exists('user_lang') ? user_lang() : get_site_default_lang(); // We can we assume this, as we will cache against it -- if subsequently code wants something else it'd be a cache miss which is fine
+9 −3
Original line number Diff line number Diff line
@@ -560,7 +560,7 @@ function _log_hack_attack_and_exit($reason, $reason_param_a = '', $reason_param_
    if (($ip2 == $ip) || ($ip2 == '') || (cms_srv('SERVER_ADDR') == $ip2)) {
        $ip2 = null;
    }
    if (function_exists('get_member')) {
    if ((function_exists('get_member')) && (!$GLOBALS['BOOTSTRAPPING'])) {
        $id = get_member();
        $username = $GLOBALS['FORUM_DRIVER']->get_username($id);
        if (is_null($username)) {
@@ -568,7 +568,7 @@ function _log_hack_attack_and_exit($reason, $reason_param_a = '', $reason_param_
        }
    } else {
        $id = db_get_first_id();
        $username = function_exists('do_lang') ? do_lang('UNKNOWN') : 'Unknown';
        $username = ((function_exists('do_lang')) && (!$GLOBALS['BOOTSTRAPPING'])) ? do_lang('UNKNOWN') : 'Unknown';
    }

    $url = cms_srv('REQUEST_URI');
@@ -689,7 +689,7 @@ function _log_hack_attack_and_exit($reason, $reason_param_a = '', $reason_param_
        $GLOBALS['SITE_DB']->query_insert('hackattack', $new_row);
    }

    if (function_exists('do_lang')) {
    if ((function_exists('do_lang')) && (!$GLOBALS['BOOTSTRAPPING'])) {
        require_code('notifications');

        $reason_full = do_lang($reason, $reason_param_a, $reason_param_b, null, get_site_default_lang());
@@ -734,12 +734,18 @@ function _log_hack_attack_and_exit($reason, $reason_param_a = '', $reason_param_
    if ($silent) {
        return;
    }

    if ((function_exists('do_lang')) && (!$GLOBALS['BOOTSTRAPPING'])) {
        if ($GLOBALS['DEV_MODE']) {
            fatal_exit(do_lang('HACK_ATTACK'));
        }
        warn_exit(do_lang_tempcode('HACK_ATTACK_USER'));
    }

    require_code('critical_errors');
    critical_error('EMERGENCY', 'Suspected hack attempt averted');
}

/**
 * Add an IP-ban.
 *