Example #1
0
                    $update_log = true;
                } elseif ($_GET['action'] == 'delete' && $_confirm) {
                    $b_id = intval($_GET['b_id']);
                    $l_id = intval($_GET['l_id']);
                    $ls_id = intval($_GET['ls_id']);
                    if ($l_id) {
                        $content .= '[CMS Block Delete: ' . $b_id . ']';
                        if ($db_log_actions == true) {
                            $db_log = array('action' => 'CMS_BLOCK_DELETE', 'desc' => $b_id . ';' . $l_id, 'target' => '');
                        }
                    } elseif ($ls_id) {
                        $content .= '[CMS Block Delete: ' . $b_id . ']';
                        if ($db_log_actions == true) {
                            $db_log = array('action' => 'CMS_BLOCK_DELETE_LS', 'desc' => $b_id . ';' . $ls_id, 'target' => '');
                        }
                    }
                    $update_log = true;
                }
            }
            break;
        default:
    }
}
if ($update_log) {
    if (!function_exists('ip_log')) {
        include IP_ROOT_PATH . 'includes/functions_mg_log.' . PHP_EXT;
    }
    ip_log($content, $db_log);
}
// unset temp-vars
unset($_mode, $_data, $_post, $_topic, $_forum, $_user, $_confirm, $_content, $_tmp1, $_tmp2, $_varary);
Example #2
0
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
{
    global $db, $cache, $config, $auth, $user, $lang, $template, $images, $theme, $tree;
    global $table_prefix, $SID, $_SID;
    global $gen_simple_header, $starttime, $base_memory_usage, $do_gzip_compress;
    global $ip_cms, $cms_config_vars, $cms_config_global_blocks, $cms_config_layouts, $cms_page;
    global $nav_separator, $nav_links;
    // Global vars needed by page header, but since we are in message_die better use default values instead of the assigned ones in case we are dying before including page_header.php
    /*
    global $meta_content;
    global $nav_pgm, $nav_add_page_title, $skip_nav_cat, $start;
    global $breadcrumbs;
    */
    //+MOD: Fix message_die for multiple errors MOD
    static $msg_history;
    if (!isset($msg_history)) {
        $msg_history = array();
    }
    $msg_history[] = array('msg_code' => $msg_code, 'msg_text' => $msg_text, 'msg_title' => $msg_title, 'err_line' => $err_line, 'err_file' => $err_file, 'sql' => htmlspecialchars($sql));
    //-MOD: Fix message_die for multiple errors MOD
    if (defined('HAS_DIED')) {
        //+MOD: Fix message_die for multiple errors MOD
        //
        // This message is printed at the end of the report.
        // Of course, you can change it to suit your own needs. ;-)
        //
        $custom_error_message = 'Please, contact the %swebmaster%s. Thank you.';
        if (!empty($config) && !empty($config['board_email'])) {
            $custom_error_message = sprintf($custom_error_message, '<a href="mailto:' . $config['board_email'] . '">', '</a>');
        } else {
            $custom_error_message = sprintf($custom_error_message, '', '');
        }
        echo "<html>\n<body>\n<b>Critical Error!</b><br />\nmessage_die() was called multiple times.<br />&nbsp;<hr />";
        for ($i = 0; $i < sizeof($msg_history); $i++) {
            echo '<b>Error #' . ($i + 1) . "</b>\n<br />\n";
            if (!empty($msg_history[$i]['msg_title'])) {
                echo '<b>' . $msg_history[$i]['msg_title'] . "</b>\n<br />\n";
            }
            echo $msg_history[$i]['msg_text'] . "\n<br /><br />\n";
            if (!empty($msg_history[$i]['err_line'])) {
                echo '<b>Line :</b> ' . $msg_history[$i]['err_line'] . '<br /><b>File :</b> ' . $msg_history[$i]['err_file'] . "</b>\n<br />\n";
            }
            if (!empty($msg_history[$i]['sql'])) {
                echo '<b>SQL :</b> ' . $msg_history[$i]['sql'] . "\n<br />\n";
            }
            echo "&nbsp;<hr />\n";
        }
        echo $custom_error_message . '<hr /><br clear="all">';
        die("</body>\n</html>");
        //-MOD: Fix message_die for multiple errors MOD
    }
    define('HAS_DIED', 1);
    $sql_store = $sql;
    // Get SQL error if we are debugging. Do this as soon as possible to prevent subsequent queries from overwriting the status of sql_error()
    if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
        $sql_error = $db->sql_error();
        $debug_text = '';
        if ($sql_error['message'] != '') {
            $debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message'];
        }
        if ($sql_store != '') {
            $debug_text .= '<br /><br />' . htmlspecialchars($sql_store);
        }
        if ($err_line != '' && $err_file != '') {
            $debug_text .= '<br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file);
        }
    }
    if (empty($user->data) && ($msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR)) {
        // Start session management
        $user->session_begin();
        $auth->acl($user->data);
        $user->setup();
        // End session management
    }
    // If the header hasn't been parsed yet... then do it!
    if (!defined('HEADER_INC') && $msg_code != CRITICAL_ERROR) {
        setup_basic_lang();
        if (empty($template) || empty($theme)) {
            $theme = setup_style($config['default_style'], $current_default_style);
        }
        $template->assign_var('HAS_DIED', true);
        define('TPL_HAS_DIED', true);
        // Load the Page Header
        if (!defined('IN_ADMIN')) {
            $parse_template = defined('IN_CMS') ? false : true;
            page_header('', $parse_template);
        } else {
            include IP_ROOT_PATH . ADM . '/page_header_admin.' . PHP_EXT;
        }
    }
    if (!defined('IN_ADMIN') && !defined('IN_CMS') && !defined('HEADER_INC_COMPLETED') && $msg_code != CRITICAL_ERROR) {
        if (!defined('TPL_HAS_DIED')) {
            $template->assign_var('HAS_DIED', true);
            define('TPL_HAS_DIED', true);
        }
        $header_tpl = empty($gen_simple_header) ? 'overall_header.tpl' : 'simple_header.tpl';
        $template->set_filenames(array('overall_header' => $header_tpl));
        $template->pparse('overall_header');
    }
    switch ($msg_code) {
        case GENERAL_MESSAGE:
            if ($msg_title == '') {
                $msg_title = $lang['Information'];
            }
            break;
        case CRITICAL_MESSAGE:
            if ($msg_title == '') {
                $msg_title = $lang['Critical_Information'];
            }
            break;
        case GENERAL_ERROR:
            if ($msg_text == '') {
                $msg_text = $lang['An_error_occured'];
            }
            if ($msg_title == '') {
                $msg_title = $lang['General_Error'];
            }
            break;
        case CRITICAL_ERROR:
            // Critical errors mean we cannot rely on _ANY_ DB information being available so we're going to dump out a simple echo'd statement
            // We force english to make sure we have at least the default language
            $config['default_lang'] = 'english';
            setup_basic_lang();
            if ($msg_text == '') {
                $msg_text = $lang['A_critical_error'];
            }
            if ($msg_title == '') {
                $msg_title = '<b>' . $lang['Critical_Error'] . '</b>';
            }
            break;
    }
    //
    // Add on DEBUG info if we've enabled debug mode and this is an error. This
    // prevents debug info being output for general messages should DEBUG be
    // set TRUE by accident (preventing confusion for the end user!)
    //
    if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
        if ($debug_text != '') {
            $msg_text = $msg_text . '<br /><br /><b><u>DEBUG MODE</u></b>' . $debug_text;
        }
    }
    // MG Logs - BEGIN
    //if (($config['mg_log_actions'] == true) && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR))
    if ($msg_code != GENERAL_MESSAGE) {
        if ($config['mg_log_actions'] || !empty($config['db_log_actions'])) {
            $db_log = array('action' => 'MESSAGE', 'desc' => $msg_code, 'target' => '');
            $error_log = array('code' => $msg_code, 'title' => $msg_title, 'text' => $msg_text);
            if (!function_exists('ip_log')) {
                @(include IP_ROOT_PATH . 'includes/functions_mg_log.' . PHP_EXT);
            }
            ip_log('[MSG_CODE: ' . $msg_code . '] - [MSG_TITLE: ' . $msg_title . '] - [MSG_TEXT: ' . $msg_text . ']', $db_log, $error_log);
        }
    }
    // MG Logs - END
    if ($msg_code != CRITICAL_ERROR) {
        if (defined('STATUS_404')) {
            send_status_line(404, 'Not Found');
        }
        if (defined('STATUS_503')) {
            send_status_line(503, 'Service Unavailable');
        }
        if (!empty($lang[$msg_text])) {
            $msg_text = $lang[$msg_text];
        }
        if (defined('IN_ADMIN')) {
            $template->set_filenames(array('message_body' => ADM_TPL . 'admin_message_body.tpl'));
        } elseif (defined('IN_CMS')) {
            $template->set_filenames(array('message_body' => COMMON_TPL . 'cms/message_body.tpl'));
        } else {
            $template->set_filenames(array('message_body' => 'message_body.tpl'));
        }
        //echo('<br />' . htmlspecialchars($template->vars['META']));
        $template->assign_vars(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text));
        if (!defined('IN_CMS')) {
            $template->pparse('message_body');
        }
        // If we have already defined the var in header, let's output it in footer as well
        if (defined('TPL_HAS_DIED')) {
            $template->assign_var('HAS_DIED', true);
        }
        if (!defined('IN_ADMIN')) {
            $template_to_parse = defined('IN_CMS') ? 'message_body' : '';
            $parse_template = defined('IN_CMS') ? false : true;
            page_footer(true, $template_to_parse, $parse_template);
        } else {
            include IP_ROOT_PATH . ADM . '/page_footer_admin.' . PHP_EXT;
        }
    } else {
        echo "<html>\n<body>\n" . $msg_title . "\n<br /><br />\n" . $msg_text . "</body>\n</html>";
    }
    garbage_collection();
    exit_handler();
    exit;
}