PHP Classes

File: aksara/Views/errors/html/error_exception.php

Recommend this page to a friend!
  Packages of Aby Dahana   Aksara   aksara/Views/errors/html/error_exception.php   Download  
File: aksara/Views/errors/html/error_exception.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Aksara
A CodeIgniter based API and CRUD generator
Author: By
Last change: Refactor code for improved readability and consistency across multiple views

- Rearranged comments and code blocks for better organization in database.php, error_404.php, error_exception.php, error_exception.php (HTML), index.php, requirement.php, security.php, system.php, and Home module views.
- Ensured consistent formatting and indentation throughout the files.
- Added missing PHP opening tags and improved variable initialization.
- Enhanced error handling and user feedback in error views.
- Updated HTML structure for better semantic clarity and accessibility.
Date: 4 months ago
Size: 5,656 bytes
 

 

Contents

Class file image Download
<?php

/**
 * @var string          $title
 * @var string          $type
 * @var int|string      $code
 * @var string          $message
 * @var string          $file
 * @var int             $line
 * @var array           $trace
 * @var \Throwable      $exception
 */
$errorId = uniqid('error', true);
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="robots" content="noindex">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="viewport" content="user-scalable=no, width=device-width, height=device-height, initial-scale=1, maximum-scale=1" />

    <title><?= esc((string) $title) ?></title>
    <style>
        <?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
    </style>

    <script>
        <?= file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.js') ?>
    </script>
</head>
<body onload="init()">

    <!-- Header -->
    <div class="header">
        <div class="container">
            <h1><?= esc((string) $title), esc($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1>
            <p>
                <?php /** @var \Throwable $exception */ ?>
                <?= nl2br(esc((string) $exception->getMessage())) ?>
                <a href="//www.google.com/search?q=<?= urlencode((string) $title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>"
                   rel="noreferrer" target="_blank">search &rarr;</a>
            </p>
        </div>
    </div>

    <!-- Source -->
    <div class="container">
        <p><b><?= esc(clean_path((string) $file)) ?></b> at line <b><?= esc((string) $line) ?></b></p>

        <?php if (is_file($file)) : ?>
            <div class="source">
                <?= static::highlightFile($file, $line, 15); ?>
            </div>
        <?php endif; ?>
    </div>

    <div class="container">
        <h2>
            Backtrace
        </h2>

        <?php foreach ($trace as $index => $row) : ?>
            <div>
                <p>
                    <!-- Trace info -->
                    <?php if (isset($row['file']) && is_file((string) $row['file'])) :?>
                        <?php
                        if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true)) {
                            echo esc((string) $row['function'] . ' ' . clean_path((string) $row['file']));
                        } else {
                            echo esc(clean_path((string) $row['file']) . ' : ' . (string) $row['line']);
                        }
                        ?>
                    <?php else: ?>
                        {PHP internal code}
                    <?php endif; ?>

                    <!-- Class/Method -->
                    <?php if (isset($row['class'])) : ?>
                        &nbsp;&nbsp;&mdash;&nbsp;&nbsp;<?= esc((string) $row['class'] . (string) $row['type'] . (string) $row['function']) ?>
                        <?php if (! empty($row['args'])) : ?>
                            <?php $argsId = $errorId . 'args' . $index ?>
                            ( <a href="#" onclick="return toggle('<?= esc($argsId, 'attr') ?>');">arguments</a> )
                            <div class="args" id="<?= esc($argsId, 'attr') ?>">
                                <table cellspacing="0">

                                <?php
                                $params = null;
                                // Reflection by name is not available for closure function
                                if (substr($row['function'], -1) !== '}') {
                                    $mirror = isset($row['class']) ? new ReflectionMethod($row['class'], $row['function']) : new ReflectionFunction($row['function']);
                                    $params = $mirror->getParameters();
                                }

                                foreach ($row['args'] as $key => $value) : ?>
                                    <tr>
                                        <td><code><?= esc(isset($params[$key]) ? '$' . $params[$key]->name : "#{$key}") ?></code></td>
                                        <td><pre><?= esc(print_r($value, true)) ?></pre></td>
                                    </tr>
                                <?php endforeach ?>

                                </table>
                            </div>
                        <?php else : ?>
                            ()
                        <?php endif; ?>
                    <?php endif; ?>

                    <?php if (! isset($row['class']) && isset($row['function'])) : ?>
                        &nbsp;&nbsp;&mdash;&nbsp;&nbsp;    <?= esc((string) $row['function']) ?>()
                    <?php endif; ?>
                </p>

                <!-- Source? -->
                <?php if (isset($row['file']) && is_file((string) $row['file']) && isset($row['class'])) : ?>
                    <div class="source">
                        <?= static::highlightFile((string) $row['file'], (int) $row['line']) ?>
                    </div>
                <?php endif; ?>
            </div>
        <?php endforeach; ?>

    </div> <!-- /container -->

    <div class="footer">
        <div class="container">

            <p>
                Displayed at <?= date('H:i:sa') ?> &mdash;
                PHP: <?= phpversion() ?>  &mdash;
                Aksara: <?= aksara('build_version') ?>
            </p>
            <p>
                <b>Aksara</b> is a <b>CodeIgniter</b> based automation platform
            </p>

        </div>
    </div>

</body>
</html>