/usr/share/doc/webcam/webcam.cgi is in webcam 3.102-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/perl
#
# send a movie (well, sort of) to the browser. Works with netscape only,
# other browsers get a static image. Uses serverpush, i.e. sends the frames
# as multipart/x-mixed-replace elements.
#
# (c) 1999 Gerd Knorr <kraxel@goldbach.in-berlin.de>
#
use strict;
# config
my $IMAGE = "$ENV{DOCUMENT_ROOT}/images/webcam.jpeg";
my $MAXSEC = 600; # 10 min timeout
###########################################################################
undef $/;
$|=1;
my $BO = "wrdlbrmpft";
my $serverpush = ($ENV{HTTP_USER_AGENT} =~ /^Mozilla/ &&
$ENV{HTTP_USER_AGENT} !~ /[Cc]ompatible/);
my $start = time;
my @st = stat($IMAGE) or die "stat $IMAGE: $!";
my $mtime = $st[9];
if ($serverpush) {
print "Content-Type: multipart/x-mixed-replace; boundary=\"$BO\"\r\n";
print "\r\n";
print "\r\n--$BO\r\n";
}
for (;;) {
# read image
open IMG, "<$IMAGE";
my $image = <IMG>;
close IMG;
# send it
print "Content-Type: image/jpeg\r\n";
printf "Content-Length: %d\r\n",length($image);
print "\r\n";
print $image;
last unless $serverpush;
# send multipart border
if (time - $start > $MAXSEC) {
print "\r\n--$BO--\r\n";
last;
} else {
print "\r\n--$BO\r\n";
}
# wait until there is a new image
foreach my $i (1 .. $MAXSEC) {
sleep 1;
@st = stat($IMAGE);
if ($st[9] != $mtime) {
$mtime = $st[9];
last;
}
}
}
exit;
|