home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet 1996 World Exposition
/
park.org.s3.amazonaws.com.7z
/
park.org.s3.amazonaws.com
/
cgi-bin
/
image-push.pl
< prev
next >
Wrap
Perl Script
|
2017-09-21
|
2KB
|
96 lines
#!/usr/local/bin/perl
#
# image-push CGI program.
# written by Andrew Rutherford of Internode Systems <andrewr@internode.com.au>
#
# where we find local WWW libraries
push(@INC, '/usr/local/etc/httpd/cgi-bin');
require 'cgi-lib.pl';
$| = 1;
$prefix = "/web/";
$default_method = "once";
$boundary = "NotVeryRandomString$$";
$this_url = $ENV{"SERVER_URL"} . $ENV{"SCRIPT_NAME"};
&parse_request ;
$method = $query{'Method'};
$file = $query{'File'};
$method = $default_method if (!defined($method));
#open(FILE, $file) || &do_error("Cannot open $file");
open(FILE, $file) || &do_error("Cannot open $file");
$i = 0;
while (<FILE>) {
chop;
s/#.*$//g;
next if /^$/;
if (/<|>|\.\.|\|/) {
&do_error("Invalid file \"$_\"");
}
$images[$i++] = $prefix . $_;
}
close(FILE);
print "Content-type: multipart/x-mixed-replace;boundary=$boundary\n";
$i = 0;
$increment = 1;
while (1) {
for (; defined($images[$i]); $i += $increment) {
print "\n--$boundary\n";
if ($images[$i] =~ /\.jpg$|\.jpeg$/) {
print "Content-type: image/jpeg\n\n";
} else {
print "Content-type: image/gif\n\n";
}
open(FILE, $images[$i]);
sysread(FILE, $this_image, (stat(FILE))[7]);
close(FILE);
print $this_image;
sleep(1) if (defined($delay));
}
last if ($method eq "once");
if ($method eq "loop") {
$i = 0;
}
if ($method eq "sweep") {
$increment = - $increment;
$i += $increment;
}
}
print "\n--$boundary--\n";
sleep(1);
exit (0);
sub do_error {
print "Content-type: text/html\n\n" .
"<title>Error: $_[0]</title>\n".
#" $query{'Method'} \n " .
# " $query{'File'} \n " .
"<body><h1>Error: $_[0]</h1></body>\n";
sleep (1);
exit (0);
}
# MethGet
# Return true if this cgi call was using the GET request, false otherwise
sub MethGet {
return ($ENV{'REQUEST_METHOD'} eq "GET");
}