Update of /cvsroot/phpmp/phpMP/includes
In directory sc8-pr-cvs1:/tmp/cvs-serv4647/includes
Added Files:
common.php error_handler.php functions.php
Log Message:
Some new files (just framework for error handling)
--- NEW FILE: common.php ---
<?php
/*
* phpMP - The PHP Modular Portal System
* Copyright (C) 2002-2003 Brian Rose and the phpMP group
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: common.php,v 1.1 2003/10/15 04:25:33 rasadam Exp $
*
*/
if(!defined('PHPMP'))
{
die;
}
// Get PHP start microtime
$php_start = explode(' ', microtime());
// Only report Core and Parse errors with Serious warnings
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Disable magic quotes runtime
set_magic_quotes_runtime(0);
// Good idea from phpBB 2.2, unset all vars incase
// register globals was on. Lazy programmers, start using
// superglobals, $_GET, $_POST, $_COOKIE, $_SERVER and $_FILES
if (@ini_get('register_globals'))
{
foreach ($_REQUEST as $var_name => $void)
{
unset(${$var_name});
}
}
// Initialise language variable
$lang = array();
// Include error handling class
include(PHPMP_ROOT.INCLUDES_DIR.'error_handler'.PHP_EXT);
$error_handler = new error_handler(&$lang);
// Because we cannot pass an object to the set_error_handler function
// (not until 4.3.0, we will have a dummy function pass things for us)
function php_error_handler($errno, $msg_text, $errfile, $errline)
{
// I don't like using global, but we have no choice here
global $error_handler;
$error_handler->php_error($errno, $msg_text, $errfile, $errline);
}
// Include general functions
include(PHPMP_ROOT.INCLUDES_DIR.'functions'.PHP_EXT);
// We want all inputted data automatically slashed. If magic_quotes_gpc
// is set (another phpBB 2.2 inspiration)
if ( !get_magic_quotes_gpc() )
{
$_COOKIE = addlashes_array($_COOKIE);
$_GET = addlashes_array($_GET);
$_POST = addlashes_array($_POST);
}
?>
--- NEW FILE: error_handler.php ---
<?php
/*
* phpMP - The PHP Modular Portal System
* Copyright (C) 2002-2003 Brian Rose and the phpMP group
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: error_handler.php,v 1.1 2003/10/15 04:25:33 rasadam Exp $
*
*/
if(!defined('PHPMP'))
{
die;
}
// PHP and Customer Error handling class
class error_handler
{
var $lang;
// Constructor
function error_handler($lang)
{
$this->lang = $lang;
}
// Errors generated by PHP parse or trigger_error
function php_error($errno, $msg_text, $errfile, $errline)
{
echo '<pre>
'.$errno.'
'.$msg_text.'
'.$errfile.'
'.$errline.'
</pre>';
die;
}
function db_error($explain, $error_message, $error_no)
{
echo '<pre>
'.$explain.'
'.$error_message.'
'.$error_number.'
</pre>';
die;
}
function sql_error($sql, $sql_explain = '', $line = NULL, $file = NULL, $error_message = '', $error_number = NULL)
{
echo '<pre>
'.$sql.'
'.$sql_explain.'
'.$line.'
'.$file.'
'.$error_message.'
'.$error_number.'
</pre>';
die;
}
}
?>
|