19 |
|
|
20 |
|
|
21 |
|
my ($query) = new CGI; |
22 |
< |
my ($doci) = ($query->param('doc') =~ /^\s*(.*?\.txt)\s*$/); |
23 |
< |
my ($doc) = "../documentation/$doci"; |
22 |
> |
my ($doc) = ($query->param('doc') =~ /^\s*(.*?\.txt)\s*$/); |
23 |
> |
$doc = "../documentation/".$doc; |
24 |
|
|
25 |
< |
print "content-type: text/html\n\n"; |
25 |
> |
print "Content-type: text/html\n\n"; |
26 |
|
|
27 |
|
print <<"END"; |
28 |
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
31 |
|
docs.cgi |
32 |
|
Web-based text file viewer and formatter. |
33 |
|
Created by pjm2 19/10/2000 |
34 |
< |
Last modified 19/10/2000 |
34 |
> |
Last modified 02/11/2000 |
35 |
|
--> |
36 |
|
|
37 |
|
<html> |
50 |
|
<td valign="top"> |
51 |
|
END |
52 |
|
|
53 |
< |
&print_file($left); |
53 |
> |
&print_html($left); |
54 |
|
|
55 |
|
print <<"END"; |
56 |
|
|
58 |
|
<td valign="top"> |
59 |
|
END |
60 |
|
|
61 |
< |
&print_file($title); |
62 |
< |
|
63 |
< |
print "<PRE>\n"; |
61 |
> |
&print_html($title); |
62 |
|
&print_file($doc); |
63 |
< |
print "</PRE>\n"; |
63 |
> |
&print_html($bottom); |
64 |
|
|
67 |
– |
&print_file($bottom); |
68 |
– |
|
65 |
|
print <<"END"; |
66 |
|
|
67 |
|
</td> |
75 |
|
|
76 |
|
exit 0; |
77 |
|
|
78 |
+ |
# Print a file, whilst escaping HTML: - |
79 |
|
sub print_file ($) { |
80 |
|
my ($filename) = @_; |
84 |
– |
print `cat $filename`; |
85 |
– |
} |
86 |
– |
|
87 |
– |
sub print_file_old ($) { |
88 |
– |
my ($filename) = @_; |
81 |
|
open(FILE, $filename) or die "Cannot open $filename: $!\n"; |
82 |
< |
while (my ($line) = <FILE>) { |
83 |
< |
print $line; |
82 |
> |
print "<pre>\n"; |
83 |
> |
# Use $_ implicitly throughout. |
84 |
> |
while (<FILE>) { |
85 |
> |
# Must do the next line first! |
86 |
> |
s/&/&/g; |
87 |
> |
s/</</g; |
88 |
> |
s/>/>/g; |
89 |
> |
s/"/"/g; |
90 |
> |
print; |
91 |
|
} |
92 |
+ |
print "</pre>"; |
93 |
|
} |
94 |
|
|
95 |
+ |
# Print a file without escaping HTML: - |
96 |
+ |
sub print_html ($) { |
97 |
+ |
my ($filename) = @_; |
98 |
+ |
print `cat $filename`; |
99 |
+ |
} |