Browse the code
| Revision log Information on the revision | |
|---|---|
| Revision: | 149 (differences) |
| Author: | xbright |
| Log message: |
* Added PHPXMLRPC * Edited the way to send notifications : don't use class.jabber.php, send a request to a bot |
| Change revision: | |
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php # ***** BEGIN LICENSE BLOCK ***** # # This file is a part of CodingTeam. See <http://www.codingteam.net>. # Copyright (C) 2007-2008 CodingTeam (See AUTHORS and THANKS for details) # # 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, version 3 only. # # 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/>. # # ***** END LICENSE BLOCK ***** /** * @file * This file contains the ErrorHandler class * * Handle all PHP and CodingTeam errors, show and exit. */ /** * ErrorHandler class */ class ErrorHandler { public $lang, $baseurl, $basedir; function __construct ($lang, $baseurl, $basedir) { $this->lang = $lang; $this->baseurl = $baseurl; $this->basedir = $basedir; if ($this->debug == 'TRUE') $this->debug = TRUE; else $this->debug = FALSE; } /** * Load the view * * Generate a pretty textarea with optional Javascript content. * @param $error * The error message. * @param $status * The error status. * @param $http (optional) * HTTP Headers to send. */ function displayError ($error, $status, $http='') { if (!empty($http)) Header('HTTP/1.0 '.$http); // Error status if ($status == 0) $erstat = _('Banal'); elseif ($status == 1) $erstat = _('Important'); elseif ($status == 2) $erstat = _('Critical'); elseif ($status == 3) $erstat = _('Code error'); else exit('Error.'); $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="{tpl:lang}" xml:lang="{tpl:lang}"> <head> <base href="http://codingteam.net/" /> <title>'._('An error has occured').' - CodingTeam</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="{tpl:cssdir}default.css" rel="stylesheet" type="text/css" /> <link href="{tpl:logosimages}ct_cube.ico" rel="shortcut icon" /> </head> <body> <div id="container"> <div id="content"> <h1>'._('An error has occured.').'</h1> <p> </p> <div class="error-{erstat}">{error}</div> <p> </p> {text} </div> </div> </body> </html>'; // Globals $temp['tpl:lang'] = $this->lang; $temp['tpl:baseurl'] = $this->baseurl; $temp['tpl:cssdir'] = 'inc/templates/'; $temp['tpl:logosimages'] = 'public/images/logos/'; $temp['erstat'] = $status; // Error if ($status == 3) { switch ($error[0]) { case 1: $errmsg = 'E_ERROR'; break; case 2: $errmsg = 'E_WARNING'; break; case 4: $errmsg = 'E_PARSE'; break; case 8: $errmsg = 'E_NOTICE'; break; case 2048: $errmsg = 'E_STRICT'; break; default: $errmsg = 'E_UNKNOWN'; } $temp['error'] = _('An error occured.').'<br />'.$error[1].' ('.$error[0].' - '.$errmsg.')<br />'.sprintf(_('In: %1s at line %2s'), $error[2], $error[3]); } else $temp['error'] = $error; if ($status == 0) $temp['text'] = '<a href="'.$baseurl.'">'._('Go to the index').'</a>'; else { ob_start(); print_r($error[4]); $datas = ob_get_clean(); $temp['text'] = '<table style="width: 100%;"> <tr><td>'._('Bug status:').'</td> <td><strong>'.$erstat.'</strong></td></tr> <tr><td style="background: #f0f0f0;">'._('Affects:').'</td> <td style="background: #f0f0f0;"><strong><a href="http://'.$_SERVER['SERVER_NAME'].'">'.$_SERVER['SERVER_NAME'].'</a></strong></td></tr> <tr><td>'._('CodingTeam version:').'</td> <td><strong>'.file_get_contents($this->basedir.'/VERSION').'</strong></td></tr> <tr><td style="width: 150px;background: #f0f0f0;">'._('Server identification:').'</td> <td style="background: #f0f0f0;">'.str_replace('address', 'strong', $_SERVER['SERVER_SIGNATURE']).'</td></tr> <tr><td>'._('Date/time:').'</td> <td>'.date('Y-m-d H:i:s').'</td></tr> </table> <p> </p> <p>'._('What to do if you can reproduce this bug.').'</p> <div class="error-"><ul> <li class="li"><strong>'._('Contact your server admin').'</strong><br /> '._('It is the first thing to do when you see a bug on your forge.').'</li> <li class="li"><strong>'._('Report this bug to upstream').'</strong><br /> '.sprintf(_('You can send all datas on this page to the CodingTeam bug tracker at this page: %s.'), '<a href="http://www.codingteam.net/project/codingteam/bugs">http://www.codingteam.net/project/codingteam/bugs</a>').'<br /> '._('Be careful not to transmit private data! Also, be sure that this bug concerns only the CodingTeam development team.').'</li> </ul></div>'; } // Parse the template foreach ($temp as $key => $value) { $search[] = '{'.$key.'}'; $replace[] = $value; } $output = str_replace($search, $replace, $html); echo $output; exit(); } } ?>

CodingTeam