<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$CI = &get_instance();
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && ($CI !== NULL)) {
    //en caso de ser ajax resolvemos con un json
    $data['debug'] = "<h4>" . $heading . "</h4>" . $message;
    $CI->output->set_status_header(404);
    $CI->output->set_content_type('application/json')->set_output(json_encode($data));
    $CI->output->_display();
} else {
    ?><!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <title>404 Page Not Found</title>
        </head>
        <body>
            <div style="text-align: center; margin-top: 50px;">
                <h1><?php echo $heading; ?></h1>
                <img src="images/404.png" alt="" style="max-width: 100%"/>
                <?php echo $message; ?>
            </div>
        </body>
    </html>
    <?php
}