line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::XHTML::Lite; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
39813
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
761
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This allows declaration use HTML::XHTML::Lite ':all'; |
16
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
17
|
|
|
|
|
|
|
# will save memory. |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
) ] ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = qw( start_page end_page getvars ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT = qw( |
25
|
|
|
|
|
|
|
start_page end_page getvars |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Preloaded methods go here. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub start_page |
34
|
|
|
|
|
|
|
{ |
35
|
1
|
|
|
1
|
|
1155
|
use HTTP::Date; |
|
1
|
|
|
|
|
6883
|
|
|
1
|
|
|
|
|
69
|
|
36
|
1
|
|
|
1
|
|
9
|
use Time::Local; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1502
|
|
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
0
|
1
|
|
$_[0]={} unless defined $_[0]; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my %p=%{$_[0]}; |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $page; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
$p{content_type}='text/html' unless defined $p{content_type}; |
44
|
0
|
0
|
|
|
|
|
my $charset=(defined $p{charset} ? uc($p{charset}) : 'UTF-8'); |
45
|
0
|
0
|
|
|
|
|
$p{title}='Untitled Document' unless defined $p{title}; |
46
|
0
|
0
|
|
|
|
|
$p{dctitle}=$p{title} unless defined $p{dctitle}; |
47
|
0
|
0
|
|
|
|
|
$p{lang}=(defined $p{lang} ? $p{lang} : 'en'); |
48
|
0
|
0
|
|
|
|
|
$p{foaftitle}='FOAF' unless defined $p{foaftitle}; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ($p{feed}) |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
0
|
|
|
|
|
$p{feedtype}="application/rss+xml" unless defined $p{feedtype}; |
53
|
0
|
0
|
|
|
|
|
$p{feedtitle}="RSS Feed for $p{title}" unless defined $p{feedtitle}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $now=time2str(time()); |
57
|
0
|
0
|
|
|
|
|
my $expires=(defined $p{expires} ? time2str(iso2time($p{expires})) : $now); |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
unless ($p{isfile}) |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
|
|
|
$page.="Expires: $expires\n"; |
62
|
0
|
|
|
|
|
|
$page.="Date: $now\n"; |
63
|
0
|
|
|
|
|
|
$page.="Content-type: $p{content_type}; charset=$charset\n\n"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
0
|
|
|
|
$page.="\n" unless $p{noxml} || $p{nohead}; |
67
|
0
|
0
|
0
|
|
|
|
$page.="\n" unless $p{nodoctype} || $p{nohead}; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$page.=<
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$p{title} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
EOT |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{description}; |
82
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{creator}; |
83
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{identifier}; |
84
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{subject}; |
85
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{rights}; |
86
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{created}; |
87
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{modified}; |
88
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{date}; |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
0
|
|
|
|
if (defined $p{legacy} && defined $p{description} && defined $p{subject}) |
|
|
|
0
|
|
|
|
|
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
|
|
|
my $kwds=$p{subject}; |
93
|
0
|
|
|
|
|
|
$kwds=~s/;/,/g; |
94
|
0
|
|
|
|
|
|
$page.="\n"; |
95
|
0
|
|
|
|
|
|
$page.="\n"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{csssrc}; |
99
|
0
|
0
|
|
|
|
|
$page.="\n" if defined $p{css}; |
100
|
0
|
0
|
|
|
|
|
$page.="\n" |
101
|
|
|
|
|
|
|
if defined $p{feed}; |
102
|
0
|
0
|
|
|
|
|
$page.="\n" |
103
|
|
|
|
|
|
|
if defined $p{foaf}; |
104
|
0
|
0
|
|
|
|
|
$page.=$p{extras} if defined $p{extras}; |
105
|
0
|
|
|
|
|
|
$page.="\n"; |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
if (defined $p{body}) |
108
|
|
|
|
|
|
|
{ |
109
|
0
|
|
|
|
|
|
$page.=$p{body}; |
110
|
0
|
|
|
|
|
|
my %footp=%p; |
111
|
0
|
|
|
|
|
|
$footp{string}=1; |
112
|
0
|
|
|
|
|
|
$page.=end_page(\%footp); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if ($p{string}) |
116
|
|
|
|
|
|
|
{ |
117
|
0
|
|
|
|
|
|
return $page; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
else |
120
|
|
|
|
|
|
|
{ |
121
|
0
|
|
|
|
|
|
print $page; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} # |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub end_page |
127
|
|
|
|
|
|
|
{ |
128
|
0
|
|
|
0
|
1
|
|
my $page; |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
$_[0]={} unless defined $_[0]; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my %p=%{$_[0]}; |
|
0
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$page.="\n\n"; |
134
|
|
|
|
|
|
|
|
135
|
0
|
0
|
|
|
|
|
if ($p{string}) |
136
|
|
|
|
|
|
|
{ |
137
|
0
|
|
|
|
|
|
return $page; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
else |
140
|
|
|
|
|
|
|
{ |
141
|
0
|
|
|
|
|
|
print $page; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub iso2time |
146
|
|
|
|
|
|
|
{ |
147
|
0
|
0
|
|
0
|
0
|
|
$_[0] =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/ or return undef; |
148
|
0
|
|
|
|
|
|
return timelocal($6,$5,$4,$3,$2-1,$1-1900); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub getvars |
152
|
|
|
|
|
|
|
{ |
153
|
|
|
|
|
|
|
# A 'Lite' version of CGI.pm's param function |
154
|
|
|
|
|
|
|
# Returns a reference to a hash of arrays of |
155
|
|
|
|
|
|
|
# name/value pairs. |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
0
|
0
|
|
my (@nvps,%vars); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# Look after anything coming from a |
160
|
|
|
|
|
|
|
# POST form |
161
|
0
|
0
|
|
|
|
|
if (lc($ENV{REQUEST_METHOD}) eq 'post') |
162
|
|
|
|
|
|
|
{ |
163
|
0
|
|
|
|
|
|
read(STDIN, my $postdata, $ENV{CONTENT_LENGTH}); |
164
|
0
|
|
|
|
|
|
push(@nvps,split(/&/,$postdata)); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# Pick up anything passed through the |
168
|
|
|
|
|
|
|
# query string, either by a GET form |
169
|
|
|
|
|
|
|
# or direct by URI |
170
|
0
|
|
|
|
|
|
my $qs=$ENV{QUERY_STRING}; |
171
|
0
|
|
|
|
|
|
$qs=~s/&/;/g; |
172
|
0
|
|
|
|
|
|
push(@nvps,split(/;/,$qs)); |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
foreach my $nv (@nvps) |
175
|
|
|
|
|
|
|
{ |
176
|
0
|
|
|
|
|
|
my @a=split(/=/,$nv); |
177
|
0
|
|
|
|
|
|
$a[0]=~tr/+/ /; |
178
|
0
|
|
|
|
|
|
$a[0]=~s/%([\da-f][\da-f])/chr(hex($1))/egi; |
|
0
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
$a[1]="" unless defined $a[1]; |
180
|
0
|
|
|
|
|
|
$a[1]=~tr/+/ /; |
181
|
0
|
|
|
|
|
|
$a[1]=~s/%([\da-f][\da-f])/chr(hex($1))/egi; |
|
0
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
push @{$vars{$a[0]}},$a[1]; |
|
0
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
} |
184
|
0
|
|
|
|
|
|
return %vars; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; |
188
|
|
|
|
|
|
|
__END__ |