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.work
< prev
next >
Wrap
Text File
|
2017-09-21
|
3KB
|
127 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';
require 'cgilib2.pl';
$| = 1;
$prefix = "/web/";
$default_method = "once";
$boundary = "NotVeryRandomString$$";
$this_url = $ENV{"SERVER_URL"} . $ENV{"SCRIPT_NAME"};
if (&ReadParse == 0) {
# &do_error("Not to be called directly");
}
print @in ;
while (($key, $value) = each(%in)) {
print "I am here\n" ;
if ((!defined($value)) || ($value eq "")) {
$value = $key;
}
if ($value =~ /^once$/i) {
if (!defined($method)) {
$method = "once";
} else {
&do_error("More than one method specified");
}
} elsif ($value =~ /^loop$/i) {
if (!defined($method)) {
$method = "loop";
} else {
&do_error("More than one method specified");
}
} elsif ($value =~ /^sweep$/i) {
if (!defined($method)) {
$method = "sweep";
} else {
&do_error("More than one method specified");
}
} elsif ($value =~ /^delay$/i) {
$delay = 1;
} else {
if (!defined($file)) {
$file = $value;
if ($file =~ /<|>|\.\.|\|/) {
&do_error("Invalid control file");
}
} else {
&do_error("More than one control file specified");
}
}
}
$method = $default_method if (!defined($method));
#open(FILE, $prefix . $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".
"<body><h1>Error: $_[0]</h1></body>\n";
sleep (1);
exit (0);
}