/** * Terminates script execution and displays message page * * @param integer $code Message code * @param boolean $header Render page header * @param string $message_title Custom page title * @param string $message_body Custom message body * @param string $redirect Optional URL to redirect after 3 seconds */ function cot_die_message($code, $header = TRUE, $message_title = '', $message_body = '', $redirect = '') { // Globals and requirements global $error_string, $out, $L, $R; $LL = is_array($L) ? $L : array(); require_once cot_langfile('message', 'core'); $L = array_merge($L, $LL); if (cot_error_found() && $_SERVER['REQUEST_METHOD'] == 'POST') { // Save the POST data cot_import_buffer_save(); if (!empty($error_string)) { // Message should not be lost cot_error($error_string); } } // Determine response header static $msg_status = array(100 => '403 Forbidden', 101 => '200 OK', 102 => '200 OK', 105 => '200 OK', 106 => '200 OK', 109 => '200 OK', 117 => '403 Forbidden', 118 => '200 OK', 151 => '403 Forbidden', 152 => '403 Forbidden', 153 => '403 Forbidden', 157 => '403 Forbidden', 300 => '200 OK', 400 => '400 Bad Request', 401 => '401 Authorization Required', 403 => '403 Forbidden', 404 => '404 Not Found', 500 => '500 Internal Server Error', 503 => '503 Service Unavailable', 602 => '403 Forbidden', 603 => '403 Forbidden', 900 => '503 Service Unavailable', 904 => '403 Forbidden', 907 => '404 Not Found', 911 => '404 Not Found', 915 => '200 OK', 916 => '200 OK', 920 => '200 OK', 930 => '403 Forbidden', 940 => '403 Forbidden', 950 => '403 Forbidden', 951 => '503 Service Unavailable'); if (!$out['meta_contenttype']) { $out['meta_contenttype'] = 'text/html'; } cot_sendheaders($out['meta_contenttype'], $msg_status[$code]); // Determine message title and body $title = empty($message_title) ? $L['msg' . $code . '_title'] : $message_title; $body = empty($message_body) ? $L['msg' . $code . '_body'] : $message_body; // Render the message page $tpl_type = defined('COT_ADMIN') ? 'core' : 'module'; $tpl_path = ''; $stylesheet = file_exists(cot_schemefile()) ? '<link rel="stylesheet" type="text/css" href="' . cot_schemefile() . '"/>' : ''; $redirect_meta = ''; if (!empty($redirect)) { if (cot_url_check($redirect)) { $redirect_meta = '<meta http-equiv="refresh" content="3; url=' . $redirect . '" />'; } } if ($header) { $tpl_path = cot_tplfile("error.{$code}", $tpl_type); if ($tpl_path) { $header = false; } else { echo '<html><head><title>' . $title . '</title><meta name="robots" content="noindex" />' . $R['code_basehref'] . $stylesheet . $redirect_meta . '</head><body><div class="block">'; } } if (empty($tpl_path)) { $tpl_path = cot_tplfile('message', $tpl_type); } if (empty($tpl_path) || !file_exists($tpl_path)) { echo $body; } else { $t = new XTemplate($tpl_path); $t->assign(array('AJAX_MODE' => COT_AJAX, 'MESSAGE_BASEHREF' => $R['code_basehref'], 'MESSAGE_STYLESHEET' => $stylesheet, 'MESSAGE_REDIRECT' => $redirect_meta, 'MESSAGE_TITLE' => $title, 'MESSAGE_BODY' => $body)); $t->parse('MAIN'); $t->out('MAIN'); } if ($header) { echo '</div></body></html>'; } /* === Hook === */ foreach (cot_getextplugins('die.message') as $pl) { include $pl; } /* ===== */ exit; }
if (empty($out['notices'])) { $out['notices'] = ''; } if (is_array($out['notices_array'])) { $notices = ''; foreach ($out['notices_array'] as $noticeRow) { $notice = is_array($noticeRow) ? cot_rc('notices_link', array('url' => $noticeRow[0], 'title' => $noticeRow[1])) : cot_rc('notices_plain', array('title' => $noticeRow)); $notices .= cot_rc('notices_notice', array('notice' => $notice)); } $out['notices'] .= cot_rc('notices_container', array('notices' => $notices)); } $out['canonical_uri'] = empty($out['canonical_uri']) ? str_replace('&', '&', $sys['canonical_url']) : $out['canonical_uri']; if (!preg_match("#^https?://.+#", $out['canonical_uri'])) { $out['canonical_uri'] = COT_ABSOLUTE_URL . $out['canonical_uri']; } $t->assign(array('HEADER_TITLE' => $out['fulltitle'], 'HEADER_COMPOPUP' => $out['compopup'], 'HEADER_LOGSTATUS' => $out['logstatus'], 'HEADER_TOPLINE' => $cfg['topline'], 'HEADER_BANNER' => $cfg['banner'], 'HEADER_GMTTIME' => $usr['gmttime'], 'HEADER_USERLIST' => $out['userlist'], 'HEADER_NOTICES' => $out['notices'], 'HEADER_NOTICES_ARRAY' => $out['notices_array'], 'HEADER_BASEHREF' => $out['basehref'], 'HEADER_META_CONTENTTYPE' => $out['meta_contenttype'], 'HEADER_META_CHARSET' => $out['meta_charset'], 'HEADER_META_DESCRIPTION' => $out['meta_desc'], 'HEADER_META_KEYWORDS' => $out['meta_keywords'], 'HEADER_META_LASTMODIFIED' => $out['meta_lastmod'], 'HEADER_HEAD' => $out['head_head'], 'HEADER_CANONICAL_URL' => $out['canonical_uri'], 'HEADER_PREV_URL' => $out['prev_uri'], 'HEADER_NEXT_URL' => $out['next_uri'], 'HEADER_COLOR_SCHEME' => cot_schemefile())); /* === Hook === */ foreach (cot_getextplugins('header.body') as $pl) { include $pl; } /* ===== */ if ($usr['id'] > 0) { $out['adminpanel'] = cot_auth('admin', 'any', 'R') ? cot_rc_link(cot_url('admin'), $L['Administration']) : ''; $out['loginout_url'] = cot_url('login', 'out=1&' . cot_xg()); $out['loginout'] = cot_rc_link($out['loginout_url'], $L['Logout']); $out['profile'] = cot_rc_link(cot_url('users', 'm=profile'), $L['Profile']); $t->assign(array('HEADER_USER_NAME' => $usr['name'], 'HEADER_USER_ADMINPANEL' => $out['adminpanel'], 'HEADER_USER_ADMINPANEL_URL' => cot_url('admin'), 'HEADER_USER_LOGINOUT' => $out['loginout'], 'HEADER_USER_LOGINOUT_URL' => $out['loginout_url'], 'HEADER_USER_PROFILE' => $out['profile'], 'HEADER_USER_PROFILE_URL' => cot_url('users', 'm=profile'), 'HEADER_USER_MESSAGES' => $usr['messages'])); /* === Hook === */ foreach (cot_getextplugins('header.user.tags') as $pl) { include $pl; }