use Win32::ODBC; # Obtain Environment Variables including passed parameters if ($ENV{'REQUEST_METHOD'} eq 'GET') { # Split the name-value pairs @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); } else { &error('request_method'); } $remhost = $ENV{'REMOTE_HOST'}; $remaddr = $ENV{'REMOTE_ADDR'}; $remuser = $ENV{'REMOTE_USER'}; %Config = ('Suffix',''); foreach $pairs (@pairs) { # Split the pair up into individual variables. # local($name, $value) = split(/=/, $pairs); # Decode the form encoding on the name and value variables. # # v1.92: remove null bytes # $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ tr/\0//d; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/\0//d; # If the field name has been specified in the %Config array, it will # # return a 1 for defined($Config{$name}}) and we should associate # # this value with the appropriate configuration variable. If this # # is not a configuration form field, put it into the associative # # array %Form, appending the value with a ', ' if there is already a # # value present. We also save the order of the form fields in the # # @Field_Order array so we can use this order for the generic sort. # if (defined($Config{$name})) { $Config{$name} = $value; } else { if ($Form{$name} ne '') { $Form{$name} = "$Form{$name}, $value"; } else { push(@Field_Order,$name); $Form{$name} = $value; } } } # The next line removes any extra spaces or new lines from the # # configuration variables, which may have been caused if your editor # # wraps lines after a certain length or if you used spaces between field # # names or environment variables. #$Config{'Suffix'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g; #$Config{'Suffix'} =~ s/(\s+)?\n+(\s+)?//g; $Form{'Actions'} =~ s/(\s+|\n)?,(\s+|\n)?/ /g; $Form{'Actions'} =~ s/(\s+)?\n+(\s+)?//g; $Form{'Feedback'} =~ s/(\s+|\n)?,(\s+|\n)?/ /g; $Form{'Feedback'} =~ s/(\s+)?\n+(\s+)?//g; $datetime = localtime(time); # file path \Inetpub\wwwdev\regfinser\_private\ # my $filepath = "\\Inetpub\\wwwybs\\ybsone\\_private\\fosfeedback_test.csv"; # my $filepath = "\\Inetpub\\wwwdev\\regfinser\\_private\\fosfeedback_test.csv"; my $filepath = "\\Inetpub\\wwwdev\\regfinser\\_private\\ybs1028a_test.csv"; print "Content-Type:text/html\n"; print "\n"; print "\n"; # Debug routine to check all variables are being passed while (my ($name, $id)= each %Form) { print "$name : has value : $Form($name)
\n"; } print "\n"; print "Entering User Details..gjhgh..\n"; print "\n"; print "\n"; print "\n"; # try to get rid of blank lines problem. chomp($Form{'Help'}); if ($Form{'Help'} eq '') { print "

ERROR form data not received

Press the back button and submit again, no data has been saved

"; print "This could of been because you double clicked the submit button, you only need to click it once"; print "

"; } else { # #while (my ($name,$id) = each %Form) { # print "
$name : $Form{$name}"; #} print "\n"; print "Entering User Details..gjhgh..\n"; print "\n"; print "\n"; print "\n"; $nowseconds=time; # Output results to file my $fileexist = 0; if (open FORMOUTPUT, join("","<",$filepath)) { $fileexist=1; } print "$fileexist\n"; print "$filepath\n\n"; (open FORMOUTPUT, join("",">>",$filepath)) or (open TESTOPENED, join("",">",$filepath)); if ($fileexist==0) { # print all headings out print "Outputting Headings\n\n"; print FORMOUTPUT "date,Manager,Briefer,No_Briefings_Deadline1,People_Briefed_Deadline1,No_Briefings_Deadline2,People_Briefed_Deadline2,No_Briefings_Late,People_Briefed_Late,Number_Of_Actions,Actions,Feedback,CB_Length,CB_Detail,CB_Relevant,CB_Understand,CB_Rating,Core_Brief_Comments,LB_Length,LB_Detail,LB_Relevant,LB_Understand,LB_Rating,Local_Brief_Comments,Help\n"; } #print "Writing Data\n\n"; print FORMOUTPUT "\"$Form{'date'}\","; #print "date: $Form{'date'}\n"; print FORMOUTPUT "\"$Form{'Manager'}\","; #print "manager: $Form{'Manager'}\n"; print FORMOUTPUT "\"$Form{'Briefer'}\","; print FORMOUTPUT "\"$Form{'No_Briefings_Deadline1'}\","; print FORMOUTPUT "\"$Form{'People_Briefed_Deadline1'}\","; print FORMOUTPUT "\"$Form{'No_Briefings_Deadline2'}\","; print FORMOUTPUT "\"$Form{'People_Briefed_Deadline2'}\","; print FORMOUTPUT "\"$Form{'No_Briefings_Late'}\","; print FORMOUTPUT "\"$Form{'People_Briefed_Late'}\","; print FORMOUTPUT "\"$Form{'Number_Of_Actions'}\","; print FORMOUTPUT "\"$Form{'Actions'}\","; print FORMOUTPUT "\"$Form{'Feedback'}\","; print FORMOUTPUT "\"$Form{'CB_Length'}\","; print FORMOUTPUT "\"$Form{'CB_Detail'}\","; print FORMOUTPUT "\"$Form{'CB_Relevant'}\","; print FORMOUTPUT "\"$Form{'CB_Understand'}\","; print FORMOUTPUT "\"$Form{'CB_Rating'}\","; print FORMOUTPUT "\"$Form{'Core_Brief_Comments'}\","; print FORMOUTPUT "\"$Form{'LB_Length'}\","; print FORMOUTPUT "\"$Form{'LB_Detail'}\","; print FORMOUTPUT "\"$Form{'LB_Relevant'}\","; print FORMOUTPUT "\"$Form{'LB_Understand'}\","; print FORMOUTPUT "\"$Form{'LB_Rating'}\","; print FORMOUTPUT "\"$Form{'Local_Brief_Comments'}\","; print FORMOUTPUT "\"$Form{'Help'}\","; printf FORMOUTPUT "\"%s\"",CurrentTime(); print FORMOUTPUT "\n"; close FORMOUTPUT; } # End else at begining if no data received print ""; # # Send the Email to the Branch Co-ordinator # { open MAIL, "|c:/windmail/windmail -t"; print MAIL "To: kjglynn\@ybs.co.uk\n"; print MAIL "From: Focus on Success Database\n"; print MAIL "Subject: Focus on Sucess Feedback\n\n"; print MAIL "The following values have been posted :\n"; print MAIL "\n"; print MAIL "Date: $Form{'date'}\n"; print MAIL "Who briefed this briefer: $Form{'Manager'}\n"; print MAIL "I am: $Form{'Briefer'}\n"; print MAIL "Number of briefings before the 5 day deadline: $Form{'No_Briefings_Deadline1'} \n"; print MAIL "Number of people briefed before the 5 day deadline: $Form{'People_Briefed_Deadline1'}\n"; print MAIL "Number of briefings before the Feedback deadline: $Form{'No_Briefings_Deadline2'} \n"; print MAIL "Number of people briefed before the Feedback deadline: $Form{'People_Briefed_Deadline2'}\n"; print MAIL "Number of briefings after the Feedback deadline: $Form{'No_Briefings_Late'} \n"; print MAIL "Number of people briefed after the Feedback deadline: $Form{'People_Briefed_Late'}\n"; #print MAIL "\n"; #print MAIL "\n"; print MAIL "How many actions the team are taking: $Form{'Number_Of_Actions'}\n"; print MAIL "Details of actions being taken: $Form{'Actions'}\n"; print MAIL "Feedback for Senior Management: $Form{'Feedback'}\n"; #print MAIL "\n"; #print MAIL "\n"; print MAIL "How long was the Corporate Brief: $Form{'CB_Length'}\n"; print MAIL "How detailed was the Corporate Brief: $Form{'CB_Detail'}\n"; print MAIL "How relevant the Corporate Brief: $Form{'CB_Relevant'}\n"; print MAIL "How easy was it to understand the Corporate Brief: $Form{'CB_Understand'}\n"; print MAIL "Your overall rating of the Corporate Brief: $Form{'CB_Rating'}\n"; print MAIL "Any other comments on the Corporate Brief: $Form{'Core_Brief_Comments'}\n"; #print MAIL "\n"; #print MAIL "\n"; print MAIL "How long was the Local Brief: $Form{'LB_Length'}\n"; print MAIL "How detailed was the Local Brief: $Form{'LB_Detail'}\n"; print MAIL "How relevant the Local Brief: $Form{'LB_Relevant'}\n"; print MAIL "How easy was it to understand the Local Brief: $Form{'LB_Understand'}\n"; print MAIL "Your overall rating of the Local Brief: $Form{'LB_Rating'}\n"; print MAIL "Any other comments on the Local Brief: $Form{'Local_Brief_Comments'}\n"; #print MAIL "\n"; #print MAIL "\n"; print MAIL "More help wanted with preparing Local Brief: $Form{'Help'}\n"; printf MAIL "Time: %s\"",CurrentTime();"\n"; print MAIL "\n.\n"; close MAIL; } exit; sub CurrentDate { my $input = $_[0]; my %Months = ('Jan','January','Feb','Febuary','Mar','March','Apr','April','May','May','Jun','June','Jul','July','Aug','August','Sep','September','Oct','October','Nov','November','Dec','December'); localtime(time)=~m/(\w+)\s(\w+)\s+(\w+)\s+(\w+)\S(\w+)\S(\w+)\s+(\w+)/; $now = "$2 $3 $7 $4:$5:$6"; $input = $now; chomp($input); if ($input=~/(\w+) (\d+) (\d+) (\d+):(\d+):\d+/) { return "$2 $1 $3"; } else { return "error"; } } sub CurrentTime { my $input = $_[0]; my %Months = ('Jan','January','Feb','Febuary','Mar','March','Apr','April','May','May','Jun','June','Jul','July','Aug','August','Sep','September','Oct','October','Nov','November','Dec','December'); localtime(time)=~m/(\w+)\s(\w+)\s+(\w+)\s+(\w+)\S(\w+)\S(\w+)\s+(\w+)/; $now = "$2 $3 $7 $4:$5:$6"; $input = $now; chomp($input); if ($input=~/(\w+) (\d+) (\d+) (\d+):(\d+):\d+/) { return "$4:$5"; } else { return "error"; } }