#!/usr/bin/perl ############################################################################## # Post survey data # # Copyright 2003 Drago Consulting Inc # ############################################################################## # COPYRIGHT NOTICE # # Copyright 2003 Drago Consulting Inc All Rights Reserved. # # Marketing Masters is granted permission to use and distribute this # # software as they desire for profit or not. # # # # postapplication may be used and modified free of charge by anyone so long # # as this copyright notice and the comments above remain intact. By using # # this code you agree to indemnify Drago Consulting Inc from any liability # # that might arise from its use. # # # # Selling the code for this program without prior written consent is # # expressly forbidden. In other words, please ask first before you try and # # make money off of my program. # # # # Obtain permission before redistributing this software over the Internet or # # in any other medium. In all cases copyright and header must remain intact.# # # # This CGI Script file will send a .htm or .jdb survey to # # the browser. # # For UNIX or Windows: # # http://www.myserver.com/ssvws.pl?file.htm # # # # Note: FILE NAME (ssweb.pl) is case sensitive for UNIX based web servers. # # # # # ############################################################################## # Revision history # # $Log: ssvws.pl,v $ # Revision 1.2 2003/11/05 21:03:37 cvs # Initial coding complete # # Revision 1.1 2003/11/03 22:01:02 cvs # Initial addition to CVS # # # Define Variables # print "Start\n"; # # This is for debugging purposes. It runs in an infinite loop until # you can start up a debugger, attach to the process, and set your # break points. Then set the variable to 'stop' to zero (0). The application # then proceeds to the set breakpoint. # #$stop = 1; #while ($stop){}; ############################################################################## # Important directory path information that you may be required to set for # # your specific web server environment. This is the only setting you need # # to make for this module. The variable $CurrentWorkingDirectory will have # # the proper value if your web server is set up to recognize the directory # # the ssweb is placed in. In this case you do not need to make any changes # # HOWEVER # # If your web server has not been set up to recognize this cgi path, then # # you must supply it. If this is the case, comment out the line that reads: # # # # $CurrentWorkingDirectory = "./"; (put a # in front of it) # # # # and # # # # remove the # from the line the reads: # # # # #$CurrentWorkingDirectory = "/var/www/cgi-bin/"; (supply your path) # # # ############################################################################## $CurrentWorkingDirectory = "./"; # #$CurrentWorkingDirectory = "C:/INETPUB/Scripts/"; # #$CurrentWorkingDirectory = "/var/www/cgi-bin/"; # # # $major_version = "5"; $minor_version = "1"; $VersionFormat = ""; $VersionFormat .= "Version"; $VersionFormat .= "



"; $VersionFormat .= "

Marketing Masters
"; $VersionFormat .= "Copyright 2004, All rights reserved
"; $VersionFormat .= "Module: %s
Version: %d.%d"; $VersionFormat .= "

\n"; # $UnknownFormat = ""; $UnknownFormat .= "Version"; $UnknownFormat .= "



"; $UnknownFormat .= "

Marketing Masters
"; $UnknownFormat .= "Copyright 2004, All rights reserved
"; $UnknownFormat .= "You have made a request to
Module: %s that is unknown
The request sent "; $UnknownFormat .= "was : %s

\n"; # # Setup default text return of information # print "Content-Type: text/html\n\n"; #Done # # Is this a "Get" request? # $Request_Method = $ENV{'REQUEST_METHOD'} ; $Query = $ENV{'QUERY_STRING'}; $QueryCased = uc $Query; #$QueryCased =~ tr/[a-z]/chr (ord ($1))/; if ($Request_Method eq "GET") { if ( $QueryCased eq "ABOUT") { printf ($VersionFormat, "SSVWS", $major_version, $minor_version); exit; } elsif ($Query eq "") { # # No filename was included in the query. Return an error # message. # print "Error - no filename\n"; print "

Error - no filename

\n"; print "There is no filename supplied. Please modify the action parameter in your form.\n"; print "\n"; exit; } # # If the get is not a the keyword "ABOUT" then presume it is a file name. # Compose a filename and see if it plays out and is accessible under the present # login rights. # $ssvwsFile = $CurrentWorkingDirectory . $Query; $ls = length($ssvwsFile); $FileExtension = uc substr ($ssvwsFile, $ls-4, $ls); # # Insure the file extension is one of the expected types. Reject all # other types specified. # if (!(($FileExtension eq ".JDB") || ($FileExtension eq ".HTM") || ($FileExtension eq ".ATM") || ($FileExtension eq ".JTM"))) { print "Error - invalid file extension\n"; print "

Error - invalid file extension

\n"; print "The file $ssvwsFile is not of the correct file type.\n"; print "\n"; exit; } # # Open the file for read access to see if it already exists. # if (!open (ssvwsHNDL, "<$ssvwsFile")) { print "Error - file does not exist\n"; print "

Error - file does not exist

\n"; print "The file $sswebFile does not exist or you do not have the proper"; print " permissions to open the file for read access."; print " Please have your system administrator create it.\n"; print "\n"; exit; } # # The file has been opened for read access. Now send it back to the requestor. # # # If the file type was a .JDB, then the data transfer has to be in binary. # if (($FileExtension eq ".JDB")) { binmode (ssvwsHNDL); binmode (STDOUT); } # # File is open. Now send the file in question back to the requestor. # Read it in blocks of 1024 bytes to keep from loading down the network. # while ($bytesread = read (ssvwsHNDL, $data, 1024)) { print $data; $size += $bytesread; } close (ssvwsHNDL); } #end GET