-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoke.pl
53 lines (37 loc) · 873 Bytes
/
joke.pl
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
#!/usr/bin/perl -T
=pod
=head1 NAME
joke.pl - Display a random joke
=head1 SYNOPSIS
http://www.server.com/cgi-bin/joke.pl
=head1 DESCRIPTION
The I<joke.pl> uses the I<fortune> program to generate a joke and
then displays the result to the user.
=head1 AUTHOR
Steve Oualline, E<lt>[email protected]<gt>.
=head1 COPYRIGHT
Copyright 2005 Steve Oualline.
This program is distributed under the GPL.
=cut
# Random joke generator
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use HTML::Entities;
# Untaint the environment
$ENV{PATH} = "/bin:/usr/bin";
delete ($ENV{qw(IFS CDPATH BASH_ENV ENV)});
print <<EOF ;
Content-type: text/html
<HTML>
<HEAD>
<TITLE>Random Joke</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<P>
EOF
my @joke = `/usr/games/fortune`;
foreach (@joke) {
print HTML::Entities::encode($_), "<BR>\n";
}