-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtmlerror.cpp
More file actions
110 lines (102 loc) · 3.75 KB
/
htmlerror.cpp
File metadata and controls
110 lines (102 loc) · 3.75 KB
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
// Copyright (c) 1999 Peter Karlsson
//
// $Id$
//
// 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, version 2
//
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <stdio.h>
#include "htmlerror.h"
struct
{
const string title, message1, message2;
} errors[MAXERROR + 1] =
{
{ "Bad request method",
"The document was requested incorrectly. Please check the referring "
"document for errors.",
"" },
{ "Unkown area",
"The area you tried to access, ",
", was not found. Please check the "
"referring document for errors." },
{ "Cannot open area",
"The area you tried to access, ",
", could not be read. "
"It probably is being accessed by another process. "
"Please try again. If the problem "
"persists, please contact the SysOp." },
{ "Nonexisting UMSGID",
"The message you tried to access (UMSGID ",
") does not exist. It might have expired. "
"If you think this problem is issued in error, please "
"contact the SysOp." },
{ "Nonexisting message",
"The message you tried to access (# ",
") does not exist. "
"It might have expired. "
"If you think this problem is issued in error, please "
"contact the SysOp." },
{ "Out of memory",
"The system ran out of memory when trying to allocate memory for ",
"" },
{ "No parameters given",
"Required arguments are missing from the request. Please check "
"the referring document for errors.",
"" },
{ "Illegal parameter format",
"The document was requested with illegal arguments: ",
". Please check the referring document for errors." },
{ "Required parameter missing",
"The document was requested without the required parameter ",
". Please check the referring document for errors." },
{ "Not logged in",
"You must be correctly logged in to access this function.",
"" },
{ "Unable to create file",
"Unable to create ",
". Please try again. If the problem persists, please contact "
"the SysOp." },
{ "Incorrect error message",
"An error occured, and when the program tried to tell it, something "
"else went wrong. This should not happen. If it did anyway, please "
"contact the SysOp, stating exactly what you did.",
"" }
};
void htmlerror(int error, const string data)
{
cout << "Pragma: no-cache" << endl;
cout << "Cache-Control: no-cache" << endl;
cout << "Content-type: text/html" << endl;
cout << "Refresh: 600" << endl;
cout << endl;
if (error < 0 || error >= MAXERROR) error = BADERROR;
cout << "<html>" << endl;
cout << "<head>" << endl;
cout << " <title>" << errors[error].title << "</title>" << endl;
cout << " <link rel=\"stylesheet\" href=\"fido.css\" type=\"text/css\">"
<< endl;
cout << "</head>" << endl;
cout << "<body>" << endl;
cout << "<h1>An error has occured</h1>" << endl;
cout << "<p>Your request could not be fulfilled." << endl;
cout << "<p>" << errors[error].message1 << data
<< errors[error].message2 << endl;
cout << "</html>" << endl;
exit(0);
}
void htmlerrori(int error, const int data)
{
char tmp[64];
sprintf(tmp, "%d", data);
htmlerror(error, tmp);
}