filtragem de erros
This commit is contained in:
16
index.php
16
index.php
@@ -23,13 +23,21 @@
|
|||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
set_error_handler(function ($severity, $message, $file, $line) {
|
||||||
|
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||||
|
});
|
||||||
|
|
||||||
$page = filter_input(INPUT_GET, "pg", FILTER_VALIDATE_INT) ?: 1;
|
$page = filter_input(INPUT_GET, "pg", FILTER_VALIDATE_INT) ?: 1;
|
||||||
$comps = ["inicio.php", "escrever.php"];
|
$comps = ["inicio.php", "escrever.php"];
|
||||||
$file = "componentes/" . $comps[$page - 1];
|
try {
|
||||||
|
$file = "componentes/" . $comps[$page - 1];
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
die("<p>Error 404, arquivo não encontrado</p>");
|
die("<p>Error 404, arquivo não encontrado</p>");
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$file = "componentes/inicio.php";
|
||||||
}
|
}
|
||||||
require_once $file;
|
require_once $file;
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user