Ejemplo n.º 1
0
    $dt = $eny->{$_g_method}($_g_id, $_REQUEST, $_ENV);
}
if (!isset($dt['errno'])) {
    exit("Bad entry return value.");
}
end:
if ($_g_display === 'html' || $_g_display === 'php') {
    if ($dt['errno'] == 0) {
        $files = array();
        $files[] = CY_HOME . '/app/html/' . $_g_module . '/' . $_g_method . '.' . $_g_display;
        $files[] = CY_HOME . '/app/html/' . $_g_module . '.' . $_g_display;
        $files[] = CY_HOME . '/app/html/default.' . $_g_display;
        foreach ($files as $i => $file) {
            if (is_file($file)) {
                break;
            }
            if ($i === 1 && $_g_display === 'html') {
                $_ENV['display'] = $_g_display = 'php';
                goto end;
            }
        }
    } else {
        $file = CY_HOME . '/app/html/error.' . $_g_display;
    }
} else {
    $file = NULL;
}
$t = new CY_Util_Output();
$t->assign($dt);
$t->render($file);
Ejemplo n.º 2
0
/**
 * 脚本执行终止
 * cy_exit可以跟据请求的不同,输入json,xml,html等不同格式的错误信息
 *
 * @author xiaoyjy@gmail.com
 *
 * @param int $errno error code int lib/util/errno.php
 * @param string $message user defined error message
 * @param CY_Util_Output $t output template
 */
function cy_exit($errno = 0, $message = NULL, $t = NULL)
{
    /* Many be used in shutdown functions. */
    $_ENV['errno'] = $errno;
    $data = [];
    /* hacked, return data by message. */
    if (is_array($message)) {
        $tmp = $message;
        $error = isset($message['error']) ? $message['error'] : NULL;
        unset($tmp['error']);
        $data += $tmp;
    } elseif (is_string($message)) {
        $error = $message;
    }
    /* First field must be 'result'. */
    $data = array('errno' => $errno, 'error' => empty($error) ? cy_strerror($errno) : $error, 'exitting' => true);
    $t == NULL && ($t = new CY_Util_Output());
    $t->assign($data);
    $file = $_ENV['display'] === 'html' || $_ENV['display'] === 'php' ? CY_HOME . '/app/html/error.' . $_ENV['display'] : NULL;
    echo $t->render($file);
    /* useful in nginx, useless in apache. */
    if (function_exists('fastcgi_finish_request')) {
        /* if use fastcgi, we may finish it first. */
        fastcgi_finish_request();
    }
    exit($errno);
}