ossp-pkg/quos/quos.cgi 1.5 -> 1.6
--- quos.cgi 2004/10/27 16:23:46 1.5
+++ quos.cgi 2004/10/28 12:00:26 1.6
@@ -30,6 +30,98 @@
use String::Divert;
use IO::File;
+# internal handling of fatal errors
+BEGIN {
+ $SIG{__DIE__} = sub {
+ my ($msg) = @_;
+ my $hint = '';
+ if ($msg =~ m|line\s+(\d+)|) {
+ my $line = $1;
+ my $io = new IO::File "<$0";
+ my @code = $io->getlines();
+ $io->close();
+ my $i = -1;
+ $hint = join("", map { s/^/sprintf("%d: ", $line+$i++)/se; $_; } @code[$line-2..$line]);
+ }
+ print STDOUT
+ "Content-Type: text/html; charset=ISO-8859-1\n" .
+ "\n" .
+ "<html>\n" .
+ " <head>\n" .
+ " <title>OSSP quos: GURU MEDITATION</title>\n" .
+ " <style type=\"text/css\">\n" .
+ " HTML {\n" .
+ " width: 100%;\n" .
+ " height: auto;\n" .
+ " }\n" .
+ " BODY {\n" .
+ " background: #cccccc;\n" .
+ " margin: 0 0 0 0;\n" .
+ " padding: 0 0 0 0;\n" .
+ " }\n" .
+ " DIV.canvas {\n" .
+ " background: #000000;\n" .
+ " border: 20px solid #000000;\n" .
+ " }\n" .
+ " DIV.error1 {\n" .
+ " border-top: 4px solid #cc3333;\n" .
+ " border-left: 4px solid #cc3333;\n" .
+ " border-right: 4px solid #cc3333;\n" .
+ " border-bottom: 4px solid #cc3333;\n" .
+ " padding: 10px 10px 10px 10px;\n" .
+ " font-family: sans-serif, helvetica, arial;\n" .
+ " background: #000000;\n" .
+ " color: #cc3333;\n" .
+ " }\n" .
+ " DIV.error2 {\n" .
+ " border-top: 4px solid #000000;\n" .
+ " border-left: 4px solid #000000;\n" .
+ " border-right: 4px solid #000000;\n" .
+ " border-bottom: 4px solid #000000;\n" .
+ " padding: 10px 10px 10px 10px;\n" .
+ " font-family: sans-serif, helvetica, arial;\n" .
+ " background: #000000;\n" .
+ " color: #cc3333;\n" .
+ " }\n" .
+ " SPAN.title {\n" .
+ " font-size: 200%;\n" .
+ " font-weight: bold;\n" .
+ " }\n" .
+ " TT.text {\n" .
+ " font-weight: bold;\n" .
+ " }\n" .
+ " </style>\n" .
+ " <script language=\"JavaScript\">\n" .
+ " var count = 0;\n" .
+ " function blinker() {\n" .
+ " var obj = document.getElementById('error');\n" .
+ " if (count++ % 2 == 0) {\n" .
+ " obj.className = 'error1';\n" .
+ " }\n" .
+ " else {\n" .
+ " obj.className = 'error2';\n" .
+ " }\n" .
+ " setTimeout('blinker()', 1000);\n" .
+ " }\n" .
+ " </script>\n" .
+ " </head>\n" .
+ " <body onLoad=\"setTimeout('blinker()', 1);\">\n" .
+ " <div class=\"canvas\">\n" .
+ " <div id=\"error\" class=\"error1\">\n" .
+ " <span class=\"title\">OSSP quos: GURU MEDITATION</span>\n" .
+ " <p>\n" .
+ " <tt class=\"text\">\n" .
+ " $msg<br>\n" .
+ " </tt>\n" .
+ " <pre>\n$hint</pre>\n" .
+ " </div>\n" .
+ " </div>\n" .
+ " </body>\n" .
+ "</html>\n";
+ exit(0);
+ };
+}
+
# create objects
my $cgi = new CGI;
my $html = new String::Divert;
|
|