-
Notifications
You must be signed in to change notification settings - Fork 90
/
curl.pm
86 lines (74 loc) · 1.55 KB
/
curl.pm
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
require "CGI.pm";
our $root="/var/www/html";
sub stitle {
my ($title)=@_;
return "<h1 class=\"pagetitle\">".CGI::escapeHTML($title)."</h1>";
}
sub title {
my $title=$_[0];
print stitle($title);
}
sub subtitle {
my $title=$_[0];
print "<h2>".CGI::escapeHTML($title)."</h2>";
}
sub where {
my @args = @_;
my $name;
my $link;
my $pic="/";
print "<div class=\"where\"><a href=\"/\">curl</a> $pic";
while(1) {
$name = shift @args;
$link = shift @args;
if($name) {
# things look ok
if($link) {
print " <a href=\"$link\">".CGI::escapeHTML($name)."</a> $pic";
}
else {
print " <b>".CGI::escapeHTML($name)."</b>";
}
}
else {
last; # get out of loop
}
}
print "</div>\n";
}
# catfile assumes a HTML-encoded file!
sub catfile {
open (CAT, $_[0]);
while(<CAT>) {
print $_;
}
close(CAT);
}
# <pre>-print a file, convert to HTML encoding
sub precatfile {
open (CAT, $_[0]);
print "<pre>\n";
while(<CAT>) {
print CGI::escapeHTML($_);
}
close(CAT);
print "</pre>\n";
}
sub header {
my ($ihead)=@_;
my $head = CGI::escapeHTML($ihead);
open(HEAD, "<$root/head.html");
while(<HEAD>) {
$_ =~ s/\<title\>curl\<\/title\>/<title>curl: $head<\/title>/;
print $_;
}
close(HEAD);
}
sub footer {
open(FOOT, "<$root/foot.html");
while(<FOOT>) {
print $_;
}
close(FOOT);
}
1;