Пример #1
0
/**
 * cpg_die()
 *
 * Replacement for the die function
 *
 * @param $msg_code
 * @param $msg_text
 * @param $error_file
 * @param $error_line
 * @param boolean $output_buffer
 * @return
 **/
function cpg_die($msg_code, $msg_text, $error_file, $error_line, $output_buffer = false)
{
    global $CONFIG, $lang_cpg_die, $template_cpg_die;
    // Simple output if theme file is not loaded
    if (!function_exists('pageheader')) {
        echo 'Fatal error :<br />' . $msg_text;
        exit;
    }
    $ob = ob_get_contents();
    if ($ob) {
        ob_end_clean();
    }
    if (function_exists('theme_cpg_die')) {
        theme_cpg_die($msg_code, $msg_text, $error_file, $error_line, $output_buffer);
        return;
    }
    $params = array('{MESSAGE}' => $msg_text, '{FILE_TXT}' => $lang_cpg_die['file'], '{FILE}' => $error_file, '{LINE_TXT}' => $lang_cpg_die['line'], '{LINE}' => $error_line, '{OUTPUT_BUFFER}' => $ob);
    if (!($CONFIG['debug_mode'] == 1 || $CONFIG['debug_mode'] == 2 && GALLERY_ADMIN_MODE)) {
        template_extract_block($template_cpg_die, 'file_line');
    }
    //if(!$output_buffer && !$CONFIG['debug_mode'])
    template_extract_block($template_cpg_die, 'output_buffer');
    pageheader($lang_cpg_die[$msg_code]);
    starttable(-1, $lang_cpg_die[$msg_code]);
    echo "<!-- cpg_die -->";
    echo template_eval($template_cpg_die, $params);
    endtable();
    pagefooter();
    exit;
}
/**
 * cpg_die()
 *
 * Replacement for the die function
 *
 * @param $msg_code
 * @param $msg_text
 * @param $error_file
 * @param $error_line
 * @param boolean $output_buffer
 * @return
 **/
function cpg_die($msg_code, $msg_text, $error_file, $error_line, $output_buffer = false)
{
    global $lang_common, $lang_errors, $CONFIG, $USER_DATA, $hdr_ip;
    // Three types of error levels: INFORMATION, ERROR, CRITICAL_ERROR.
    // There used to be a clumsy method for error mesages that didn't work well with i18n.
    // Let's add some more logic to this: try to get the translation
    // for the error type from the language file. If that fails, use the hard-coded
    // English string.
    // Record access denied messages to the log
    if ($msg_text == $lang_errors['access_denied'] && $CONFIG['log_mode'] != 0) {
        log_write("Denied privileged access to " . basename($error_file) . " by user {$USER_DATA['user_name']} at IP {$hdr_ip}", CPG_SECURITY_LOG);
    }
    // Record invalid form token messages to the log
    if ($msg_text == $lang_errors['invalid_form_token'] && $CONFIG['log_mode'] != 0) {
        log_write("Invalid form token encountered for " . basename($error_file) . " by user {$USER_DATA['user_name']} at IP {$hdr_ip}", CPG_SECURITY_LOG);
    }
    if ($msg_code == INFORMATION) {
        //$msg_icon = 'info'; not used anymore?
        $css_class = 'cpg_message_info';
        if ($lang_common['information'] != '') {
            $msg_string = $lang_common['information'];
        } else {
            $msg_string = 'Information';
        }
    } elseif ($msg_code == ERROR) {
        //$msg_icon = 'warning'; not used anymore?
        $css_class = 'cpg_message_warning';
        if ($lang_errors['error'] != '') {
            $msg_string = $lang_errors['error'];
        } else {
            $msg_string = 'Error';
        }
    } elseif ($msg_code == CRITICAL_ERROR) {
        //$msg_icon = 'stop'; not used anymore?
        $css_class = 'cpg_message_error';
        if ($lang_errors['critical_error'] != '') {
            $msg_string = $lang_errors['critical_error'];
        } else {
            $msg_string = 'Critical error';
        }
    }
    // Simple output if theme file is not loaded
    if (!function_exists('pageheader')) {
        echo 'Fatal error :<br />' . $msg_text;
        exit;
    }
    $ob = ob_get_contents();
    if ($ob) {
        ob_end_clean();
    }
    theme_cpg_die($msg_code, $msg_text, $msg_string, $css_class, $error_file, $error_line, $output_buffer, $ob);
    exit;
}