aboutsummaryrefslogtreecommitdiff
path: root/error.cgi
blob: bd5cf1bdd144e92de8b5e2f96cfa0a227af7be5b (plain)
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
#!/usr/bin/env ruby

############################################################################
# Copyright 2009,2010 Benjamin Kellermann                                  #
#                                                                          #
# This file is part of dudle.                                              #
#                                                                          #
# Dudle 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.                                      #
#                                                                          #
# Dudle 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 dudle.  If not, see <http://www.gnu.org/licenses/>.           #
############################################################################

require "cgi"
$cgi = CGI.new
require "config"
require "html"

$h = HTML.new("Error")
$h.add_css("/default.css","default",true)
$h << <<END
<div id='main'>
<div id='content'>
<h1>Error</h1>
END

def urlescape(str)
	CGI.escapeHTML(CGI.escape(str).gsub("+","%20"))
end

errormessagebody = <<MESSAGE
Hi!

I found a bug in your application at #{SITEURL}.
I did the following:

<please describe what you did>
<e.g., I wanted to sent a comment to the poll.>

I am using <please state your browser and operating system>
MESSAGE

if defined?(ERRORLOG)
	begin
		a = File.open(ERRORLOG,"r").to_a
	rescue Exception => e
		errorstr = "Exception while opening #{ERRORLOG}:\n#{e}"
	else
		s = [a.pop]
		s << a.pop while s.last.scan(/^\[([^\]]*)\] \[/).flatten[0] == a.last.scan(/^\[([^\]]*)\] \[/).flatten[0] || a.last =~ /^[^\[]/
		errorstr = s.reverse.join
	end

	errormessagebody += <<MESSAGE

The following error was printed:
#{errorstr}
MESSAGE

end
errormessagebody += <<MESSAGE

Yours,

MESSAGE

	$h << <<ERROR
An error occured while executing dudle.<br/>
Please report you browser, operating system, and what you did to
<a href='mailto:#{BUGREPORTMAIL}?subject=#{urlescape("Bug in dudle")}&amp;body=#{urlescape(errormessagebody)}'>#{BUGREPORTMAIL}</a>. 
ERROR

if (errorstr)
	
	$h << <<ERROR
<br/>
Please include the following as well:
<pre style='background:#DDD;padding : 1em'>#{errorstr}</pre>
ERROR
end

$h << "</div></div>"
$h.out($cgi)