PHP Classes

How Can PHP Handle Error 500 and Other HTTP Errors with the Package eXperience Error Pages: Implement personalized HTTP error handling pages

Recommend this page to a friend!
  Info   View files Example   View files View files (43)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-05-04 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
experience-errorpage 1.0Custom (specified...5HTTP, PHP 5, Global
Description 

Author

This package can implement personalized HTTP error-handling pages.

It provides an error-handling PHP script that can get the HTTP error code from a URL parameter and uses a template script to show a personalized message depending on the type of HTTP error.

The error handling script uses a configuration script to define details of processing the error like:

- The email address of an administrator to notify about errors

- The current site URL

- The path of a file to log error details

- A list of subject titles to display for the error names

- A list of HTTP error codes the error handling script should support

Picture of Luca Liscio
  Performance   Level  
Innovation award
Innovation award
Nominee: 2x

 

Example

<?php
   
   
/*
     * errore.php
     *
     * __ __ _
     * ___\ \/ /_ __ ___ _ __(_) ___ _ __ ___ ___
     * / _ \\ /| '_ \ / _ \ '__| |/ _ \ '_ \ / __/ _ \
     * | __// \| |_) | __/ | | | __/ | | | (_| __/
     * \___/_/\_\ .__/ \___|_| |_|\___|_| |_|\___\___|
     * |_| HZKnight free PHP Scripts
     *
     * lucliscio <lucliscio@h0model.org>, ITALY
     *
     * EroorPage ver.0.1.0
     *
     * -------------------------------------------------------------------------------------------
     * Lincense
     * -------------------------------------------------------------------------------------------
     * Copyright (C)2023 HZKnight
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     * GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public License
     * along with this program. If not, see <http://www.gnu.org/licenses/agpl-3.0.html>.
     * -------------------------------------------------------------------------------------------
     */

   
namespace Experience\ErrorPages;
   
    use
phpbrowscap\Browscap;
   
   
/**
     * Personalizzed server error pages
     *
     * @author lucliscio <lucliscio@h0model.org>
     * @version v0.1.0 2023/04/24 07:56:20
     * @copyright Copyright 2023 HZKnight
     * @copyright Copyright 2013 Luca Liscio
     * @license http://www.gnu.org/licenses/agpl-3.0.html GNU/AGPL3
     *
     * @package eXperience
     * @subpackage ErrorPages
     * @filesource
     */

   
require_once 'lib/logger/hzlogger.class.php';
    require_once
'config.inc.php';
    require_once
'lib/function.inc.php';
    require_once
'lib/Browscap.php';

   
$log[] = Core\HZLogger::getLogger('arturo');
   
$log[] = Core\HZLogger::getLogger("debora");

   
/* echo "<pre>";
    var_dump(Core\HZLogger::$_instace);
    echo "</pre>"; */
   
   
$bc = new Browscap('./temp/cache/');
   
$bc->doAutoUpdate = false;
   
   
$result = (array_key_exists('err', $_GET)) ? $_GET['err'] : "000";

    if (
$result != "400" && $result != "401" && $result != "403" && $result != "404" && $result != "500"){
       
$result="000";
    }

    require_once
'assets/template/error.tpl';

    if (
$log[$result] == 'Y') notifica("L",$result);

    if (
$email[$result] == 'Y') notifica("M",$result);

?>


Details

eXperience ErrorPages

Experience-ErrorPages Release Pre-release) Licence Issue Code Climate Open Source Love

Licences

  • Experience ErrorPages code ©2022 by HZKnight is licensed under AGPL 3.0
  • Experience ErrorPages User Guide and all related documentation ©2022 by HZKnight is licensed under CC BY 4.0

Descriprion

Personalizzed Web Server error pages


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder image.settings (2 files)
Files folder imagedoc (14 files, 1 directory)
Files folder imagesrc (4 files, 3 directories)
Accessible without login Plain text file .project Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads  
 100%
Total:0
This week:0