| 3 |
lars |
1 |
<?php
|
|
|
2 |
/* $Id: Error_Object.class.php 8 2007-04-24 14:17:50Z markus $ */
|
|
|
3 |
|
|
|
4 |
/**
|
|
|
5 |
* This Class builds an Error Object and could
|
|
|
6 |
* be verrified with Error::isError.
|
|
|
7 |
*
|
|
|
8 |
* PHP versions 4 and 5
|
|
|
9 |
*
|
|
|
10 |
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
|
|
11 |
* that is available through the world-wide-web at the following URI:
|
|
|
12 |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
|
|
13 |
* the PHP License and are unable to obtain it through the web, please
|
|
|
14 |
* send a note to license@php.net so we can mail you a copy immediately.
|
|
|
15 |
*
|
|
|
16 |
* @category Shop
|
|
|
17 |
* @package Error_Object
|
|
|
18 |
* @author Markus Niewerth <markus@weban.de>
|
|
|
19 |
* @copyright 1997-2005 The PHP Group
|
|
|
20 |
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
|
|
21 |
* @since File available since Release 1.0.1
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
// {{{ constants
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
// }}}
|
|
|
29 |
// {{{ GLOBALS
|
|
|
30 |
|
|
|
31 |
// -------------------
|
|
|
32 |
// IF any put in here!
|
|
|
33 |
// -------------------
|
|
|
34 |
|
|
|
35 |
// }}}
|
|
|
36 |
// {{{ Error_Object
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Diese Klasse bildet ein Error_Object und kann
|
|
|
40 |
* mit dem Methoden aufruf $Error->isError($obj)
|
|
|
41 |
* geprüft werden.
|
|
|
42 |
*
|
|
|
43 |
* @category CMS
|
|
|
44 |
* @package Error_Object
|
|
|
45 |
* @author Markus Niewerth <markus@weban.de>
|
|
|
46 |
* @author Lars Tiefland <tiefland@weban.de>
|
|
|
47 |
* @copyright 1997-2007 Webagentur Niewerth
|
|
|
48 |
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
|
|
49 |
* @link http://server2/intranet/3_0.txt
|
|
|
50 |
* @see Functions
|
|
|
51 |
* @since Class available since Release 1.1
|
|
|
52 |
*/
|
|
|
53 |
|
|
|
54 |
class Error_Object {
|
|
|
55 |
|
|
|
56 |
// {{{ properties
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* The Shops ID number.
|
|
|
60 |
*
|
|
|
61 |
* Its a very important ID, cause the
|
|
|
62 |
* ID is saved in any userdefined data-
|
|
|
63 |
* base entry like articles a.s.o.
|
|
|
64 |
*
|
|
|
65 |
* @var int
|
|
|
66 |
*/
|
|
|
67 |
var $_timestamp;
|
|
|
68 |
var $_logdate;
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* The Shop language.
|
|
|
72 |
*
|
|
|
73 |
* The Base language is DE. Note that this
|
|
|
74 |
* value could be mixed! But stadard is DE
|
|
|
75 |
*
|
|
|
76 |
* @var array
|
|
|
77 |
*/
|
|
|
78 |
var $_line;
|
|
|
79 |
|
|
|
80 |
var $_etype;
|
|
|
81 |
|
|
|
82 |
var $_admin;
|
|
|
83 |
|
|
|
84 |
var $_sysinfos;
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
// }}}
|
|
|
88 |
// {{{ Error_Object()
|
|
|
89 |
|
|
|
90 |
/**
|
|
|
91 |
* Base Constructor
|
|
|
92 |
*
|
|
|
93 |
* @param object
|
|
|
94 |
* @param object
|
|
|
95 |
* @return Weban_Shop
|
|
|
96 |
*/
|
|
|
97 |
function Error_Object ($errno, $errmsg, $filename, $linenum, $vars, $adminmail, $logfile="/var/log/php/weban_shop_error.log")
|
|
|
98 |
{
|
|
|
99 |
// timestamp for the error entry
|
|
|
100 |
$this->_logdate = date("Y-m-d H:i:s (T)");
|
|
|
101 |
|
|
|
102 |
// define an assoc array of error string
|
|
|
103 |
// in reality the only entries we should
|
|
|
104 |
// consider are E_WARNING, E_NOTICE, E_USER_ERROR,
|
|
|
105 |
// E_USER_WARNING and E_USER_NOTICE
|
|
|
106 |
$this->_etype = array
|
|
|
107 |
(
|
|
|
108 |
E_ERROR => 'Error',
|
|
|
109 |
E_WARNING => 'Warning',
|
|
|
110 |
E_PARSE => 'Parsing Error',
|
|
|
111 |
E_NOTICE => 'Notice',
|
|
|
112 |
E_CORE_ERROR => 'Core Error',
|
|
|
113 |
E_CORE_WARNING => 'Core Warning',
|
|
|
114 |
E_COMPILE_ERROR => 'Compile Error',
|
|
|
115 |
E_COMPILE_WARNING => 'Compile Warning',
|
|
|
116 |
E_USER_ERROR => 'User Error',
|
|
|
117 |
E_USER_WARNING => 'User Warning',
|
|
|
118 |
E_USER_NOTICE => 'User Notice',
|
|
|
119 |
E_STRICT => 'Runtime Notice',
|
|
|
120 |
E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
|
|
|
121 |
);
|
|
|
122 |
|
|
|
123 |
$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
|
|
|
124 |
|
|
|
125 |
$err = "<errorentry>\n";
|
|
|
126 |
$err .= "\t<datetime>" . $this->_logdate . "</datetime>\n";
|
|
|
127 |
$err .= "\t<errornum>" . $errno . "</errornum>\n";
|
|
|
128 |
$err .= "\t<errortype>" . $this->_etype[$errno] . "</errortype>\n";
|
|
|
129 |
$err .= "\t<errormsg>" . $errmsg . "</errormsg>\n";
|
|
|
130 |
$err .= "\t<scriptname>" . $filename . "</scriptname>\n";
|
|
|
131 |
$err .= "\t<scriptlinenum>" . $linenum . "</scriptlinenum>\n";
|
|
|
132 |
|
|
|
133 |
if (in_array($errno, $user_errors))
|
|
|
134 |
{
|
|
|
135 |
$this->_sysinfos = wddx_serialize_value ($vars, "Variables");
|
|
|
136 |
$err .= "\t<vartrace>" . wddx_serialize_value ($vars, "Variables") . "</vartrace>\n";
|
|
|
137 |
}
|
|
|
138 |
$err .= "</errorentry>\n\n";
|
|
|
139 |
|
|
|
140 |
// for testing
|
|
|
141 |
// echo $err;
|
|
|
142 |
|
|
|
143 |
// save to the error log, and e-mail me if there is a critical user error
|
|
|
144 |
error_log($err, 3, $logfile);
|
|
|
145 |
|
|
|
146 |
if ($errno == E_USER_ERROR)
|
|
|
147 |
{
|
|
|
148 |
mail($adminmail, $_SESSION['INI']['userError'], $err);
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
}
|
|
|
152 |
// }}}
|
|
|
153 |
}
|
|
|
154 |
// }}}
|
|
|
155 |
|
|
|
156 |
/*
|
|
|
157 |
* Local variables:
|
|
|
158 |
* tab-width: 4
|
|
|
159 |
* c-basic-offset: 4
|
|
|
160 |
* c-hanging-comment-ender-p: nil
|
|
|
161 |
* End:
|
|
|
162 |
*/
|
|
|
163 |
?>
|