Ejemplo n.º 1
0
/**
 * Prints program execution backtrace.
 *
 * @param bool $clear_screen If TRUE displays backtrace only. Otherwise it will be printed in normal flow.
 * @see cot_assert(), cot_vardump()
 */
function cot_backtrace($clear_screen = TRUE)
{
    if ($clear_screen) {
        ob_end_clean();
        cot_sendheaders('text/plain');
    }
    debug_print_backtrace();
    if ($clear_screen) {
        die;
    }
}
Ejemplo n.º 2
0
 * [BEGIN_COT_EXT]
 * Hooks=ajax
 * [END_COT_EXT]
 */
/**
 * Location Selector for Cotonti
 *
 * @package locationselector
 * @version 2.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
$country = cot_import('country', 'R', 'TXT');
$region = cot_import('region', 'R', 'INT');
cot_sendheaders();
if (isset($_REQUEST['country'])) {
    $regions = array();
    if ($country != '0') {
        $regions = cot_getregions($country);
    }
    $region_selectbox = array('regions' => array(0 => $L['select_region']) + $regions, 'disabled' => empty($country) || count($regions) == 0 ? 1 : 0);
    echo json_encode($region_selectbox);
    exit;
} else {
    $cities = !empty($region) ? cot_getcities($region) : array();
    $city_selectbox = array('cities' => array(0 => $L['select_city']) + $cities, 'disabled' => !$region || count($cities) == 0 ? 1 : 0);
    echo json_encode($city_selectbox);
    exit;
}
Ejemplo n.º 3
0
/**
 * 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;
}
Ejemplo n.º 4
0
$html = Resources::render();
if ($html) {
    $out['head_head'] = $html . $out['head_head'];
}
$out['meta_contenttype'] = $cfg['xmlclient'] ? 'application/xml' : 'text/html';
$out['basehref'] = $R['code_basehref'];
$out['meta_charset'] = 'UTF-8';
$out['meta_desc'] = empty($out['desc']) ? $cfg['subtitle'] : htmlspecialchars($out['desc']);
$out['meta_keywords'] = empty($out['keywords']) ? $cfg['metakeywords'] : htmlspecialchars($out['keywords']);
$out['meta_lastmod'] = gmdate('D, d M Y H:i:s');
$out['head_head'] .= $out['head'];
if ($sys['noindex']) {
    $out['head_head'] .= $R['code_noindex'];
}
if (!headers_sent()) {
    cot_sendheaders($out['meta_contenttype'], isset($env['status']) ? $env['status'] : '200 OK', $env['last_modified']);
}
if (!COT_AJAX) {
    $mtpl_type = defined('COT_ADMIN') || defined('COT_MESSAGE') && $_SESSION['s_run_admin'] && cot_auth('admin', 'any', 'R') ? 'core' : 'module';
    if ($cfg['enablecustomhf']) {
        $mtpl_base = defined('COT_PLUG') && !empty($e) ? array('header', $e) : array('header', $env['location']);
    } else {
        $mtpl_base = 'header';
    }
    $t = new XTemplate(cot_tplfile($mtpl_base, $mtpl_type));
    /* === Hook === */
    foreach (cot_getextplugins('header.main') as $pl) {
        include $pl;
    }
    /* ===== */
    if (empty($out['notices'])) {
Ejemplo n.º 5
0
        require_once cot_incfile($n, $is_module ? 'module' : 'plug');
    }
}
if (!empty($a) && file_exists(cot_incfile('cateditor', 'plug', 'admin.' . $sub . '.' . $a))) {
    require_once cot_incfile('cateditor', 'plug', 'admin.' . $sub . '.' . $a);
} elseif ($id > 0) {
    require_once cot_incfile('cateditor', 'plug', 'admin.edit');
    $status['editor'] = form_structure_editor($id);
} else {
    $parentid = cot_import('parentid', 'G', 'INT');
    require_once cot_incfile('cateditor', 'plug', 'admin.new');
    $status['editor'] = form_structure_new($parentid);
}
/*
if (file_exists(cot_incfile('cateditor', 'plug', 'admin.'.$sub)))
{
	$t = new XTemplate(cot_tplfile('cateditor.admin.'.$sub, 'plug'));
	require_once cot_incfile('cateditor', 'plug', 'admin.'.$sub);
	$t->parse('MAIN');
	$adminmain = $t->text('MAIN');
}
*/
if ($status['editor']) {
    $status['editor'] = preg_replace('#<form\\s+[^>]*method=["\']?post["\']?[^>]*>#i', '$0' . cot_xp(), $status['editor']);
}
cot_sendheaders('application/json');
$status['id'] = (int) $id;
$status['x'] = $sys['xk'];
//cot_watch($status, $_GET);
echo json_encode($status);
exit;