Flasher Archive
#!/usr/bin/perl
push(@INC,"/www/cgi-bin");
require 'cgi-lib.pl';
# Get the input
%cgivars= &getcgivars ;
#----------------- start of &getcgivars() module ----------------------
# Read all CGI vars into an associative array.
# If multiple input fields have the same name, they are concatenated into
# one array element and delimited with the \0 character (which fails if
# the input has any \0 characters, very unlikely but conceivably possible).
# Currently only supports Content-Type of application/x-www-form-urlencoded.
sub getcgivars {
local($in, %in) ;
local($name, $value) ;
# First, read entire string of CGI vars into $in
if ( ($ENV{'REQUEST_METHOD'} eq 'GET') ||
($ENV{'REQUEST_METHOD'} eq 'HEAD') ) {
$in= $ENV{'QUERY_STRING'} ;
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
if ($ENV{'CONTENT_TYPE'}=~ m#^application/x-www-form-urlencoded$#i) {
$ENV{'CONTENT_LENGTH'}
|| &HTMLdie("No Content-Length sent with the POST request.") ;
read(STDIN, $in, $ENV{'CONTENT_LENGTH'}) ;
} else {
&HTMLdie("Unsupported Content-Type: $ENV{'CONTENT_TYPE'}") ;
}
} else {
&HTMLdie("Script was called with unsupported REQUEST_METHOD.") ;
}
# Resolve and unencode name/value pairs into %in
foreach (split('&', $in)) {
s/\+/ /g ;
($name, $value)= split('=', $_, 2) ;
$name=~ s/%(..)/chr(hex($1))/ge ;
$value=~ s/%(..)/chr(hex($1))/ge ;
$in{$name}.= "\0" if defined($in{$name}) ; # concatenate multiple vars
$in{$name}.= $value ;
}
return %in ;
}
# Print the CGI response header, required for all HTML output
# Note the extra \n, to send the blank line
print "Content-type: text/html\n\n" ;
$datafile = "data.txt";
# Begin the Editing of the Guestbook File
open (FILE,"$datafile") || die "Can't Open $datafile: $!\n";
@LINES=;
close(FILE);
$SIZE=@LINES;
# Open Link File to Output
open (DATA,">>$datafile") || die "Can't Open $datafile: $!\n";
for ($i=0;$i<=$SIZE;$i++) {
$_=$LINES[$i];
if (//) {
foreach (keys %cgivars) {
print DATA "$_ = $cgivars{$_}\n";
}
print DATA "\n\n";
}
}
close (DATA);
print "";
print "";
print "

