#!/bin/perl #require 'jcode.pl'; #################################### # Main #################################### # Get Form Information &parse_form; # Get variables &get_variables; if($counter eq "") { $count="0"; } else { # Get Query Number &get_number; } # Return the user HTML &return_html; ####################### # Parse Form Subroutine sub parse_form { $buffer = $ENV{'QUERY_STRING'}; # Split the name-value pairs @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } ############### # Get Query number sub get_number { open (COUNT,"$counter"); $count=; close (COUNT); open (COUNT,">$counter"); $count=$count+1; print COUNT ($count); close (COUNT); } ############### # Get Variables sub get_variables { $filename =$FORM{'filename'}; $counter =$FORM{'counter'}; } ####################### # return html sub return_html { open(FHTML,"$filename") || die $!; @main = ; close(FHTML); print "Content-type: text/html\n\n"; foreach $main_line (@main) { if ($main_line =~ //) { print "$count"; } else { print "$main_line"; } } }