From 2457a0ed411461617d2d7048515d1901197ebb17 Mon Sep 17 00:00:00 2001 From: Siri Reiter Date: Thu, 21 Dec 2017 22:37:09 +0100 Subject: Rename and duplicate form. --- feedback.cgi | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ form.cgi | 104 ----------------------------------------------------------- kontakt.cgi | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 208 insertions(+), 104 deletions(-) create mode 100755 feedback.cgi delete mode 100755 form.cgi create mode 100755 kontakt.cgi diff --git a/feedback.cgi b/feedback.cgi new file mode 100755 index 0000000..9df30e7 --- /dev/null +++ b/feedback.cgi @@ -0,0 +1,104 @@ +#!/usr/bin/perl -w + +use CGI::FormBuilder; + +my $build_path = '../build'; + +# TODO: check if protocol-agnostic URL works +my $webroot = 'https://byvandring.nu/feedback/'; +my $req_path = $build_path . '/html/feedback/index.html'; +my $ack_path = $build_path . '/html/feedback/tak/index.html'; + +my $webmaster = 'info@byvandring.nu'; +#my $frontdesk = 'info@byvandring.nu'; +my $frontdesk = 'siri@jones.dk'; +my $helpdesk = 'siri@jones.dk'; + +# Set this to 1 for a separate confirmation page +my ($confirm) = 1; + +# Built-in email validation is too simplistic +my $valid_email = '/^[+_A-Za-z0-9-]+(\.[+_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[_A-Za-z0-9-]+)$/'; + +my $form = CGI::FormBuilder->new( + lang => 'da', + title => 'Feedback til Byvandring.nu', + method => 'POST', + fields => [qw/ + kommentar + postnr + email + /], + validate => { + postnr => INT, + email => $valid_email, + _email => $valid_email, #fake check to silence warning of variable used only once + }, + required => [qw/ + kommentar + /], + messages => ':da_DK', + submit => ['Send oplysningerne'], + action => $webroot, #avoids loosing submitted values when redirected from other site +); + +$form->field( + name => 'postnr', + label => 'Postnummer', + size => 5, + comment => '(hvis du har lyst)' +); +$form->field( + name => 'email', + comment => '(hvis du vil kontaktes igen)' +); +$form->field( + name => 'kommentar', + type => 'textarea', + rows => 3, +); + +my ($form_required_text) = $form->{opt}{messages}{form_required_text}; +my ($mail_from) = $webmaster; +my ($mail_to, $mail_subject); + +if ($form->submitted) { + $infostring = "Tak for din feedback!"; + if ($form->validate) { + $mail_to = $frontdesk; + $mail_subject = 'Feedback til Byvandring.nu'; + } else { + $mail_to = "$frontdesk, $helpdesk"; + $mail_subject = 'FEJL ved feedback til Byvandring.nu'; + $infostring .= "\n

OBS! Der var fejl i et eller flere af felterne. Informationerne er sendt uanset, men det anbefales at gå tilbage, checke at alle felter er udfyldt korrekt, og derefter sende igen."; + $confirm = 0; + }; + # Abuse subject to add additional headers +# $mail_subject .= "\n" . 'Content-Type: text/plain; charset="ISO-8859-1";'; +# $mail_subject .= "\n" . 'Content-Transfer-Encoding: 8bit'; + $form->mailresults( + to => $mail_to, + from => $mail_from, + subject => "$mail_subject", + ); + if ($confirm) { + $infostring .= "\n

Følgende informationer er blevet sendt:"; + $form->{opt}{messages}{form_confirm_text} = "$infostring"; + print $form->confirm( + header => 1, + template => $ack_path + ); + } else { + print $form->render( + header => 1, + sticky => (! $form->validate), +#FIXME text => $infostring, + template => $req_path + ); + } +} else { + print $form->render( + header => 1, + template => $req_path + ); +} diff --git a/form.cgi b/form.cgi deleted file mode 100755 index 9df30e7..0000000 --- a/form.cgi +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/perl -w - -use CGI::FormBuilder; - -my $build_path = '../build'; - -# TODO: check if protocol-agnostic URL works -my $webroot = 'https://byvandring.nu/feedback/'; -my $req_path = $build_path . '/html/feedback/index.html'; -my $ack_path = $build_path . '/html/feedback/tak/index.html'; - -my $webmaster = 'info@byvandring.nu'; -#my $frontdesk = 'info@byvandring.nu'; -my $frontdesk = 'siri@jones.dk'; -my $helpdesk = 'siri@jones.dk'; - -# Set this to 1 for a separate confirmation page -my ($confirm) = 1; - -# Built-in email validation is too simplistic -my $valid_email = '/^[+_A-Za-z0-9-]+(\.[+_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[_A-Za-z0-9-]+)$/'; - -my $form = CGI::FormBuilder->new( - lang => 'da', - title => 'Feedback til Byvandring.nu', - method => 'POST', - fields => [qw/ - kommentar - postnr - email - /], - validate => { - postnr => INT, - email => $valid_email, - _email => $valid_email, #fake check to silence warning of variable used only once - }, - required => [qw/ - kommentar - /], - messages => ':da_DK', - submit => ['Send oplysningerne'], - action => $webroot, #avoids loosing submitted values when redirected from other site -); - -$form->field( - name => 'postnr', - label => 'Postnummer', - size => 5, - comment => '(hvis du har lyst)' -); -$form->field( - name => 'email', - comment => '(hvis du vil kontaktes igen)' -); -$form->field( - name => 'kommentar', - type => 'textarea', - rows => 3, -); - -my ($form_required_text) = $form->{opt}{messages}{form_required_text}; -my ($mail_from) = $webmaster; -my ($mail_to, $mail_subject); - -if ($form->submitted) { - $infostring = "Tak for din feedback!"; - if ($form->validate) { - $mail_to = $frontdesk; - $mail_subject = 'Feedback til Byvandring.nu'; - } else { - $mail_to = "$frontdesk, $helpdesk"; - $mail_subject = 'FEJL ved feedback til Byvandring.nu'; - $infostring .= "\n

OBS! Der var fejl i et eller flere af felterne. Informationerne er sendt uanset, men det anbefales at gå tilbage, checke at alle felter er udfyldt korrekt, og derefter sende igen."; - $confirm = 0; - }; - # Abuse subject to add additional headers -# $mail_subject .= "\n" . 'Content-Type: text/plain; charset="ISO-8859-1";'; -# $mail_subject .= "\n" . 'Content-Transfer-Encoding: 8bit'; - $form->mailresults( - to => $mail_to, - from => $mail_from, - subject => "$mail_subject", - ); - if ($confirm) { - $infostring .= "\n

Følgende informationer er blevet sendt:"; - $form->{opt}{messages}{form_confirm_text} = "$infostring"; - print $form->confirm( - header => 1, - template => $ack_path - ); - } else { - print $form->render( - header => 1, - sticky => (! $form->validate), -#FIXME text => $infostring, - template => $req_path - ); - } -} else { - print $form->render( - header => 1, - template => $req_path - ); -} diff --git a/kontakt.cgi b/kontakt.cgi new file mode 100755 index 0000000..9df30e7 --- /dev/null +++ b/kontakt.cgi @@ -0,0 +1,104 @@ +#!/usr/bin/perl -w + +use CGI::FormBuilder; + +my $build_path = '../build'; + +# TODO: check if protocol-agnostic URL works +my $webroot = 'https://byvandring.nu/feedback/'; +my $req_path = $build_path . '/html/feedback/index.html'; +my $ack_path = $build_path . '/html/feedback/tak/index.html'; + +my $webmaster = 'info@byvandring.nu'; +#my $frontdesk = 'info@byvandring.nu'; +my $frontdesk = 'siri@jones.dk'; +my $helpdesk = 'siri@jones.dk'; + +# Set this to 1 for a separate confirmation page +my ($confirm) = 1; + +# Built-in email validation is too simplistic +my $valid_email = '/^[+_A-Za-z0-9-]+(\.[+_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[_A-Za-z0-9-]+)$/'; + +my $form = CGI::FormBuilder->new( + lang => 'da', + title => 'Feedback til Byvandring.nu', + method => 'POST', + fields => [qw/ + kommentar + postnr + email + /], + validate => { + postnr => INT, + email => $valid_email, + _email => $valid_email, #fake check to silence warning of variable used only once + }, + required => [qw/ + kommentar + /], + messages => ':da_DK', + submit => ['Send oplysningerne'], + action => $webroot, #avoids loosing submitted values when redirected from other site +); + +$form->field( + name => 'postnr', + label => 'Postnummer', + size => 5, + comment => '(hvis du har lyst)' +); +$form->field( + name => 'email', + comment => '(hvis du vil kontaktes igen)' +); +$form->field( + name => 'kommentar', + type => 'textarea', + rows => 3, +); + +my ($form_required_text) = $form->{opt}{messages}{form_required_text}; +my ($mail_from) = $webmaster; +my ($mail_to, $mail_subject); + +if ($form->submitted) { + $infostring = "Tak for din feedback!"; + if ($form->validate) { + $mail_to = $frontdesk; + $mail_subject = 'Feedback til Byvandring.nu'; + } else { + $mail_to = "$frontdesk, $helpdesk"; + $mail_subject = 'FEJL ved feedback til Byvandring.nu'; + $infostring .= "\n

OBS! Der var fejl i et eller flere af felterne. Informationerne er sendt uanset, men det anbefales at gå tilbage, checke at alle felter er udfyldt korrekt, og derefter sende igen."; + $confirm = 0; + }; + # Abuse subject to add additional headers +# $mail_subject .= "\n" . 'Content-Type: text/plain; charset="ISO-8859-1";'; +# $mail_subject .= "\n" . 'Content-Transfer-Encoding: 8bit'; + $form->mailresults( + to => $mail_to, + from => $mail_from, + subject => "$mail_subject", + ); + if ($confirm) { + $infostring .= "\n

Følgende informationer er blevet sendt:"; + $form->{opt}{messages}{form_confirm_text} = "$infostring"; + print $form->confirm( + header => 1, + template => $ack_path + ); + } else { + print $form->render( + header => 1, + sticky => (! $form->validate), +#FIXME text => $infostring, + template => $req_path + ); + } +} else { + print $form->render( + header => 1, + template => $req_path + ); +} -- cgit v1.2.3