DemoGuestBook.pm

filter: Statementstmt 16.3% 54 / 330 Branchbran 0.0% 0 / 86 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 31.0% 9 / 29 Podpod 5.0% 1 / 20 totaltotal 12.9% 64 / 494 CC 54 SCAR 35.4
CC
54
Cov
12%
send_email_message
90.0
main_dispatch
72.0
read_guest_book
56.0
CRAP 34.3
« CGI/Portable/AppStatic.pm ↑ Summary DemoMailForm.pm »
1 =head1 NAME
2  
3 DemoGuestBook - Demo of CGI::Portable that implements a complete guest
4 book with unlimited questions that also e-mails submissions to the website owner.
5  
6 =cut
7  
8 ######################################################################
9  
10 package DemoGuestBook;
11 1 require 5.004;
12  
13 # Copyright (c) 1999-2004, Darren R. Duncan. All rights reserved. This module
14 # is free software; you can redistribute it and/or modify it under the same terms
15 # as Perl itself. However, I do request that this copyright information and
16 # credits remain attached to the file. If you modify this module and
17 # redistribute a changed version then please attach a note listing the
18 # modifications. This module is available "as-is" and the author can not be held
19 # accountable for any problems resulting from its use.
20  
21 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use vars qw($VERSION @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 $VERSION = '0.50';
25  
26 ######################################################################
27  
28 =head1 DEPENDENCIES
29  
30 =head2 Perl Version
31  
32 5.004
33  
34 =head2 Standard Modules
35  
36 Fcntl
37 Symbol
38 Net::SMTP 2.15 (earlier versions may work)
39  
40 =head2 Nonstandard Modules
41  
42 CGI::Portable 0.50
43 CGI::Portable::AppStatic 0.50
44 CGI::MultiValuedHash 1.09
45 HTML::FormTemplate 2.021
46  
47 =cut
48  
49 ######################################################################
50  
51 1 ▶use Fcntl qw(:DEFAULT :flock);
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 ▶use Symbol;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use CGI::Portable 0.50;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use CGI::Portable::AppStatic 0.50;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 @ISA = qw(CGI::Portable::AppStatic);
56 1 ▶use CGI::MultiValuedHash 1.09;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 1 ▶use HTML::FormTemplate 2.021;
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 ######################################################################
60  
61 =head1 SYNOPSIS
62  
63 =head2 Use Default Question
64  
65 #!/usr/bin/perl
66 use strict;
67 use warnings;
68  
69 require CGI::Portable;
70 my $globals = CGI::Portable->new();
71  
72 use Cwd;
73 $globals->file_path_root( cwd() ); # let us default to current working dir
74 $globals->file_path_delimiter( $^O=~/Mac/i ? ":" : $^O=~/Win/i ? "\\" : "/" );
75  
76 require CGI::Portable::AdapterCGI;
77 my $io = CGI::Portable::AdapterCGI->new();
78 $io->fetch_user_input( $globals );
79  
80 $globals->default_application_title( 'Demo Guest Book' );
81 $globals->default_maintainer_name( 'Tony Simons' );
82 $globals->default_maintainer_email_address( 'tony@aardvark.net' );
83  
84 my %CONFIG = (
85 fn_messages => 'guestbook_messages.txt', # file in simple Boulder format
86 );
87  
88 $globals->current_user_path_level( 1 );
89 $globals->set_prefs( \%CONFIG );
90 $globals->call_component( 'DemoGuestBook' );
91  
92 $io->send_user_output( $globals );
93  
94 1;
95  
96 =head2 Use Custom Questions Defined Here
97  
98 my %CONFIG = (
99 fn_messages => 'guestbook_messages.txt', # file in simple Boulder format
100 custom_fd => 1,
101 field_defn => [
102 {
103 visible_title => "What's your age?",
104 type => 'textfield',
105 name => 'age',
106 is_required => 1,
107 validation_rule => '\d',
108 error_message => 'You must enter a number.',
109 }, {
110 visible_title => "What's the combination?",
111 type => 'checkbox_group',
112 name => 'words',
113 'values' => ['eenie', 'meenie', 'minie', 'moe'],
114 default => ['eenie', 'minie'],
115 labels => [qw( This That And Another )],
116 }, {
117 visible_title => "Who do you love?",
118 type => 'textfield',
119 name => 'name',
120 }, {
121 visible_title => "What's your favorite colour?",
122 type => 'popup_menu',
123 name => 'color',
124 'values' => ['red', 'green', 'blue', 'chartreuse'],
125 },
126 ],
127 );
128  
129 =head2 Use Custom Questions Defined In Perl File
130  
131 my %CONFIG = (
132 fn_messages => 'guestbook_messages.txt', # file in simple Boulder format
133 custom_fd => 1,
134 field_defn => 'guestbook_questions.txt', # do Perl code to make array ref
135 );
136  
137 =head2 Use Custom Questions Defined In simple Boulder File
138  
139 my %CONFIG = (
140 fn_messages => 'guestbook_messages.txt', # file in simple Boulder format
141 custom_fd => 1,
142 field_defn => 'guestbook_questions.txt', # file in simple Boulder format
143 fd_in_seqf => 1,
144 );
145  
146 =head2 Default To Signing Mode When Mode Not Specified In User Path
147  
148 my %CONFIG = (
149 fn_messages => 'guestbook_messages.txt',
150 sign_by_default => 1,
151 );
152  
153 =head2 Show Email Addresses In Message Listings (Default Is No Show)
154  
155 my %CONFIG = (
156 fn_messages => 'guestbook_messages.txt',
157 msg_list_show_email => 1,
158 );
159  
160 =head2 Customize Subject Of Your Emails
161  
162 my %CONFIG = (
163 fn_messages => 'guestbook_messages.txt',
164 email_subj => 'Your Visitor Has Left A Message',
165 );
166  
167 =head2 Customize Webpage Intro Text
168  
169 my %CONFIG = (
170 fn_messages => 'guestbook_messages.txt',
171 msg_new_title => 'Leave A Message', # custom title for new messages
172 msg_new_head => <<__endquote, # custom heading for new messages
173 <h1>Leave A Message</h1>
174 <p>Please leave a message after the beep. Answer the questions as faithfully
175 and truthfully as you can, as we have a lie detector set up and any false
176 answers will be met with spam.</p>
177 __endquote
178 msg_list_title => 'Previous Reflections', # custom title when reading
179 msg_list_head => <<__endquote, # custom heading for reading
180 <h1>Wise Words That You Never Wrote</h1>
181 <p>Here are the messages that previous visitors wrote. Please stay awhile
182 and soak in the goodness. You never know what you don't read.</p>
183 __endquote
184 );
185  
186 =head1 DESCRIPTION
187  
188 This Perl 5 object class is part of a demonstration of CGI::Portable in use.
189 It is one of a set of "application components" that takes its settings and user
190 input through CGI::Portable and uses that class to send its user output.
191 This demo module set can be used together to implement a web site complete with
192 static html pages, e-mail forms, guest books, segmented text document display,
193 usage tracking, and url-forwarding. Of course, true to the intent of
194 CGI::Portable, each of the modules in this demo set can be used independantly
195 of the others.
196  
197 =head1 SYNTAX
198  
199 This class does not export any functions or methods, so you need to call them
200 using object notation. This means using B<Class-E<gt>function()> for functions
201 and B<$object-E<gt>method()> for methods. If you are inheriting this class for
202 your own modules, then that often means something like B<$self-E<gt>method()>.
203  
204 =head1 PUBLIC FUNCTIONS AND METHODS
205  
206 =head2 main( GLOBALS )
207  
208 You invoke this method to run the application component that is encapsulated by
209 this class. The required argument GLOBALS is an CGI::Portable object that
210 you have previously configured to hold the instance settings and user input for
211 this class. When this method returns then the encapsulated application will
212 have finished and you can get its user output from the CGI::Portable object.
213  
214 =head1 MODES THAT THIS MODULE OPERATES IN
215  
216 DemoGuestBook has separate modes for signing the guest book and viewing
217 the existing messages. The signing mode is accessed through the relative
218 user path /sign. The reading mode is accessed through /read. Each of the modes
219 is designed to present links going to the other mode. When the GuestBook is
220 started up it defaults to the reading mode when no valid mode is specified.
221 If the preference 'sign_by_default' is true then GuestBook defaults to the
222 signing mode instead.
223  
224 =head1 PREFERENCES HANDLED BY THIS MODULE
225  
226 I<This POD is coming when I get the time to write it.>
227  
228 custom_fd # if true, we use a custom list of
229 # questions in the form; otherwise, we simply have a "message" field.
230 field_defn # instruc for how to make form fields
231 # If array ref, this is taken literally as list of definitions.
232 # Otherwise, this is name of a file containing the definitions.
233 # Field definitions are processed by HTML::FormTemplate, so please see
234 # its POD to know what options you have in your forms.
235 fd_in_seqf # if true, above file is of the
236 # format that is a simplified form of Boulder; else it is Perl code
237  
238 fn_messages # file messages go in, if filed
239  
240 sign_by_default # if true, we default to the signing screen; false is read
241
242 msg_list_show_email # if true, guest emails are shown, else they are not
243  
244 email_subj # if set, use when sending e-mails
245  
246 msg_new_title # custom title for new messages
247 msg_new_head # custom heading for new messages
248  
249 msg_list_title # custom title when reading
250 msg_list_head # custom heading for reading
251  
252 =cut
253  
254 ######################################################################
255  
256 # Names of properties for objects of this class are declared here:
257 1 my $KEY_SITE_GLOBALS = 'site_globals'; # hold global site values
258  
259 # Keys for items in site page preferences:
260 1 my $PKEY_CUSTOM_FD = 'custom_fd'; # if true, we use a custom list of
261 # questions in the form; otherwise, we simply have a "message" field.
262 1 my $PKEY_FIELD_DEFN = 'field_defn'; # instruc for how to make form fields
263 # If array ref, this is taken literally as list of definitions.
264 # Otherwise, this is name of a file containing the definitions.
265 # Field definitions are processed by HTML::FormTemplate, so please see
266 # its POD to know what options you have in your forms.
267 1 my $PKEY_FD_IN_SEQF = 'fd_in_seqf'; # if true, above file is of the
268 # format that is a simplified form of Boulder; else it is Perl code
269 1 my $PKEY_FN_MESSAGES = 'fn_messages'; # file messages go in, if filed
270 1 my $PKEY_SIGN_BY_DEFAULT = 'sign_by_default'; # if true, default to sign mode
271 1 my $PKEY_MSG_LIST_SHOW_EMAIL = 'msg_list_show_email'; # true to show emails
272 1 my $PKEY_EMAIL_SUBJ = 'email_subj'; # if set, use when sending e-mails
273 1 my $PKEY_MSG_NEW_TITLE = 'msg_new_title'; # custom title for new messages
274 1 my $PKEY_MSG_NEW_HEAD = 'msg_new_head'; # custom heading for new messages
275 1 my $PKEY_MSG_LIST_TITLE = 'msg_list_title'; # custom title when reading
276 1 my $PKEY_MSG_LIST_HEAD = 'msg_list_head'; # custom heading for reading
277  
278 # Names of the fields in our html form:
279 1 my $FFN_NAMEREAL = 'namereal'; # user's real name
280 1 my $FFN_EMAIL = 'email'; # user's e-mail address
281 1 my $FFN_WANTCOPY = 'wantcopy'; # true if sender wants a copy
282  
283 # This is where the user's message goes, by default.
284 1 my @DEF_FORM_QUESTIONS = ( {
285 visible_title => "Your Message",
286 type => 'textarea',
287 name => 'message',
288 rows => 5,
289 columns => 50,
290 is_required => 1,
291 error_message => 'You must enter a message.',
292 } );
293  
294 # Extra fields in guest book log file
295 1 my $LFN_SUBMIT_DATE = 'submit_date';
296 1 my $LFN_SUBMIT_DOMAIN = 'submit_domain';
297  
298 # Constant values used in this class go here:
299 1 my $EMPTY_FIELD_ECHO_STRING = '(no answer)';
300 1 my $VRP_SIGN = 'sign'; # in this sub path is the book signing page
301 # if no sub path is chosen, we view guest book by default
302 1 my $VRP_READ = 'read'; # in this sub path is the message listing page
303 # if no sub path is chosen, we default to this
304 1 my $TOKEN_SIGN = '__gb_mode_sign_token__'; # embed in text, then replace
305 1 my $TOKEN_READ = '__gb_mode_read_token__'; # embed in text, then replace
306  
307 ######################################################################
308  
309 0 ▶sub main {
Subroutine main: not called CC=3 SCAR=24.8
Pod documented
310 0 my ($class, $globals) = @_;
311 0 ▶ my $self = bless( {}, ref($class) || $class );
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
312  
313 0 ▶ UNIVERSAL::isa( $globals, 'CGI::Portable' ) or
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($globals, "CGI::Portable") or die "initializer is not a valid CGI::Portable object" 0 0 0
314 die "initializer is not a valid CGI::Portable object";
315  
316 0 $self->set_static_low_replace( $globals );
317  
318 0 $self->{$KEY_SITE_GLOBALS} = $globals;
319 0 $self->main_dispatch();
320  
321 0 $self->set_static_high_replace( $globals );
322 0 $self->set_static_attach_unordered( $globals );
323 0 $self->set_static_attach_ordered( $globals );
324 0 $self->set_static_search_and_replace( $globals );
325 }
326  
327 ######################################################################
328  
329 0 ▶sub main_dispatch {
Subroutine main_dispatch: not called CC=8 SCAR=42.8
Pod undocumented
330 0 my $self = shift( @_ );
331 0 my $globals = $self->{$KEY_SITE_GLOBALS};
332  
333 SWITCH: {
334 0 my $ra_field_defs = $self->get_field_definitions(); # sets err on probl
335 0 ▶ if( $globals->get_error() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($globals->get_error) 0 0 0
336 0 $self->no_questions_error();
337 0 $globals->add_no_error(); # clears it now dealt with
338 0 last SWITCH;
339 }
340  
341 0 my $form = HTML::FormTemplate->new();
342 0 $form->form_submit_url( $globals->recall_url() );
343 0 $form->field_definitions( $ra_field_defs );
344  
345 0 ▶ unless( $self->is_in_signing_mode() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_in_signing_mode) 0 0 0
346 0 $self->read_guest_book( $form );
347 0 last SWITCH;
348 }
349  
350 0 $form->user_input( $globals->user_post() )->trim_bounding_whitespace();
351  
352 0 ▶ if( $form->new_form() ) { # if we're called first time
Branch: 1 branch
BranchTrueFalseTotal
if ($form->new_form) 0 0 0
353 0 $self->new_message( $form );
354 0 last SWITCH;
355 }
356  
357 0 ▶ if( $form->validate_form_input() ) { # if there were errors
Branch: 1 branch
BranchTrueFalseTotal
if ($form->validate_form_input) 0 0 0
358 0 $self->invalid_input( $form );
359 0 last SWITCH;
360 }
361
362 0 ▶ $self->send_mail_to_me( $form ) or last SWITCH;
Branch: 1 branch
BranchTrueFalseTotal
$self->send_mail_to_me($form) or last SWITCH 0 0 0
363
364 0 ▶ $self->sign_guest_book( $form ) or last SWITCH;
Branch: 1 branch
BranchTrueFalseTotal
$self->sign_guest_book($form) or last SWITCH 0 0 0
365  
366 0 $self->mail_me_and_sign_guest_ok( $form );
367
368 0 ▶ if( $globals->user_post_param( $FFN_WANTCOPY ) eq 'on' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($globals->user_post_param($FFN_WANTCOPY) eq "on") 0 0 0
369 0 $self->send_mail_to_writer( $form );
370 }
371 }
372  
373 $globals->page_search_and_replace( {
374 0 $TOKEN_SIGN => $globals->url_as_string( $VRP_SIGN ),
375 $TOKEN_READ => $globals->url_as_string( $VRP_READ ),
376 } );
377 }
378  
379 ######################################################################
380  
381 0 ▶sub get_field_definitions {
Subroutine get_field_definitions: not called CC=1 SCAR=6.9
Pod undocumented
382 0 my $self = shift( @_ );
383 0 my @field_definitions = ();
384  
385 0 push( @field_definitions,
386 {
387 visible_title => "Your Name",
388 type => 'textfield',
389 name => $FFN_NAMEREAL,
390 size => 30,
391 is_required => 1,
392 error_message => 'You must enter your name.',
393 exclude_in_echo => 1,
394 }, {
395 visible_title => "Your E-mail",
396 type => 'textfield',
397 name => $FFN_EMAIL,
398 size => 30,
399 is_required => 1,
400 validation_rule => '\S\@\S',
401 help_message => 'E-mails are in the form "user@domain".',
402 error_message => 'You must enter your e-mail.',
403 exclude_in_echo => 1,
404 }, {
405 visible_title => "Keep A Copy",
406 type => 'checkbox',
407 name => $FFN_WANTCOPY,
408 nolabel => 1,
409 help_message => "If checked, a copy of this message is e-mailed to you.",
410 exclude_in_echo => 1,
411 },
412 );
413  
414 0 push( @field_definitions, @{$self->get_question_field_defs()} );
415  
416 0 push( @field_definitions,
417 {
418 type => 'submit',
419 label => 'Post',
420 }, {
421 type => 'reset',
422 label => 'Clear',
423 },
424 );
425  
426 0 return( \@field_definitions );
427 }
428  
429 ######################################################################
430  
431 0 ▶sub get_question_field_defs {
Subroutine get_question_field_defs: not called CC=4 SCAR=30.0
Pod undocumented
432 0 my $self = shift( @_ );
433 0 my $globals = $self->{$KEY_SITE_GLOBALS};
434 0 my $rh_prefs = $globals->get_prefs_ref();
435
436 # check if we are using default or custom questions
437 0 ▶ unless( $rh_prefs->{$PKEY_CUSTOM_FD} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rh_prefs->{$PKEY_CUSTOM_FD}) 0 0 0
438 0 return( \@DEF_FORM_QUESTIONS ); # using default
439 }
440
441 0 my $field_defn = $rh_prefs->{$PKEY_FIELD_DEFN};
442
443 # check if we have actual custom questions or filename to them
444 # check if question file is executable Perl or not
445 0 ▶ unless( $rh_prefs->{$PKEY_FD_IN_SEQF} ) { # it is Perl file
Branch: 1 branch
BranchTrueFalseTotal
unless ($rh_prefs->{$PKEY_FD_IN_SEQF}) 0 0 0
446 0 return( $globals->resolve_prefs_node_to_array( $field_defn ) );
447 }
448
449 # we will now get questions from a simple Boulder formatted file
450 0 ▶ return( $self->fetch_all_records( $field_defn ) || [] );
Condition0%0/2
$self->fetch_all_records($field_defn) || []
l!l
00
MC/DC0%0/1
$self->fetch_all_records($field_defn) || []
$self->fetch_all_records($field_defn)
Truth table0%0/2
A
A= $self->fetch_all_records($field_defn)
Aresult
11
00
451 }
452  
453 ######################################################################
454  
455 0 ▶sub no_questions_error {
Subroutine no_questions_error: not called CC=1 SCAR=6.9
Pod undocumented
456 0 my $self = shift( @_ );
457 0 my $globals = $self->{$KEY_SITE_GLOBALS};
458  
459 0 $globals->page_title( "Error Starting GuestBook" );
460  
461 0 $globals->set_page_body( <<__endquote );
462 0 <h1>@{[$globals->page_title()]}</h1>
463  
464 <p>I'm sorry, but an error has occurred while trying to start
465 the Guest Book. We are missing critical settings information
466 that is required to operate. Specifically, we don't know what
467 questions we are supposed to ask you. Here are some details about
468 what caused this problem:</p>
469  
470 0 <p>@{[$globals->get_error()]}</p>
471  
472 0 @{[$self->get_amendment_message()]}
473 __endquote
474 }
475  
476 ######################################################################
477  
478 0 ▶sub is_in_signing_mode {
Subroutine is_in_signing_mode: not called CC=3 SCAR=24.8
Pod undocumented
479 0 my ($self, $form) = @_;
480 0 my $globals = $self->{$KEY_SITE_GLOBALS};
481 0 my $raw_mode = $globals->current_user_path_element();
482 0 ▶ $raw_mode eq $VRP_SIGN and return( 1 );
Branch: 1 branch
BranchTrueFalseTotal
$raw_mode eq $VRP_SIGN and return 1 0 0 0
483 0 ▶ $raw_mode eq $VRP_READ and return( 0 );
Branch: 1 branch
BranchTrueFalseTotal
$raw_mode eq $VRP_READ and return 0 0 0 0
484 0 return( $globals->pref( $PKEY_SIGN_BY_DEFAULT ) );
485 }
486  
487 ######################################################################
488  
489 0 ▶sub read_guest_book {
Subroutine read_guest_book: not called CC=7 SCAR=40.3
Pod undocumented
490 0 my ($self, $form) = @_;
491 0 my $globals = $self->{$KEY_SITE_GLOBALS};
492  
493 0 my $filename = $globals->pref( $PKEY_FN_MESSAGES );
494 0 my @message_list = $self->fetch_all_records( $filename, 1 );
495  
496 0 ▶ if( my $err_msg = $globals->get_error() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err_msg = $globals->get_error) 0 0 0
497 0 $globals->page_title( "Error Reading GuestBook Postings" );
498  
499 0 $globals->set_page_body( <<__endquote );
500 0 <h1>@{[$globals->page_title()]}</h1>
501  
502 <p>I'm sorry, but an error has occurred while trying to read the
503 existing guest book messages from the log file, meaning that I can't
504 show you any.</p>
505  
506 <p>details: $err_msg</p>
507  
508 0 @{[$self->get_amendment_message()]}
509 __endquote
510  
511 0 return( 0 );
512 }
513  
514 0 ▶ unless( @message_list ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@message_list) 0 0 0
515 0 $globals->page_title( "Empty Guest Book" );
516  
517 0 $globals->set_page_body( <<__endquote );
518 0 <h1>@{[$globals->page_title()]}</h1>
519  
520 <p>The guest book currently has no messages in it, as either none
521 were successfully posted or they were deleted since then. You can
522 still <a href="$TOKEN_SIGN">sign</a> it yourself, however.</p>
523 __endquote
524  
525 0 return( 1 );
526 }
527  
528 0 my @message_html = ();
529
530 0 my $show_emails = $globals->pref( $PKEY_MSG_LIST_SHOW_EMAIL );
531 0 foreach my $message (reverse @message_list) {
532 0 $form->user_input( $message );
533 0 my $name_real = $message->fetch_value( $FFN_NAMEREAL );
534 0 ▶ my $email = $show_emails ?
Branch: 1 branch
BranchTrueFalseTotal
$show_emails ? : 0 0 0
535 '&lt;'.$message->fetch_value( $FFN_EMAIL ).'&gt;' : '';
536 0 my $submit_date = $message->fetch_value( $LFN_SUBMIT_DATE );
537 0 push( @message_html, "<h3>From $name_real $email at $submit_date:</h3>" );
538 0 push( @message_html,
539 $form->make_html_input_echo( 1, 1, $EMPTY_FIELD_ECHO_STRING ) );
540 0 push( @message_html, "\n<hr />" );
541 }
542 0 pop( @message_html ); # get rid of trailing <hr />
543
544 0 $globals->set_page_body( \@message_html );
545
546 0 $globals->prepend_page_body( <<__endquote );
547 <p>You may also <a href="$TOKEN_SIGN">sign</a>
548 this guest book yourself, if you wish.</p>
549 __endquote
550 0 $globals->append_page_body( <<__endquote );
551 <p>You may also <a href="$TOKEN_SIGN">sign</a>
552 this guest book yourself, if you wish.</p>
553 __endquote
554  
555 0 ▶ $globals->page_title( $globals->pref( $PKEY_MSG_LIST_TITLE ) ||
Condition0%0/2
$globals->pref($PKEY_MSG_LIST_TITLE) || 'Guest Book Messages'
l!l
00
MC/DC0%0/1
$globals->pref($PKEY_MSG_LIST_TITLE) || 'Guest Book Messages'
$globals->pref($PKEY_MSG_LIST_TITLE)
Truth table0%0/2
A
A= $globals->pref($PKEY_MSG_LIST_TITLE)
Aresult
11
00
556 "Guest Book Messages" );
557  
558 0 ▶ $globals->prepend_page_body(
Condition0%0/2
$globals->pref($PKEY_MSG_LIST_HEAD) || "<h1>@{[$globals->page_title];}</h1>\n\n<p>Messages are ordered from newest to oldest.</p>\n"
l!l
00
MC/DC0%0/1
$globals->pref($PKEY_MSG_LIST_HEAD) || "<h1>@{[$globals->page_title];}</h1>\n\n<p>Messages are ordered from newest to oldest.</p>\n"
$globals->pref($PKEY_MSG_LIST_HEAD)
Truth table0%0/2
A
A= $globals->pref($PKEY_MSG_LIST_HEAD)
Aresult
11
00
559 $globals->pref( $PKEY_MSG_LIST_HEAD ) || <<__endquote );
560 0 <h1>@{[$globals->page_title()]}</h1>
561  
562 <p>Messages are ordered from newest to oldest.</p>
563 __endquote
564  
565 0 return( 1 );
566 }
567  
568 ######################################################################
569  
570 0 ▶sub new_message {
Subroutine new_message: not called CC=3 SCAR=24.8
Pod undocumented
571 0 my ($self, $form) = @_;
572 0 my $globals = $self->{$KEY_SITE_GLOBALS};
573  
574 0 ▶ $globals->page_title( $globals->pref( $PKEY_MSG_NEW_TITLE ) ||
Condition0%0/2
$globals->pref($PKEY_MSG_NEW_TITLE) || 'Sign the Guest Book'
l!l
00
MC/DC0%0/1
$globals->pref($PKEY_MSG_NEW_TITLE) || 'Sign the Guest Book'
$globals->pref($PKEY_MSG_NEW_TITLE)
Truth table0%0/2
A
A= $globals->pref($PKEY_MSG_NEW_TITLE)
Aresult
11
00
575 "Sign the Guest Book" );
576  
577 0 ▶ $globals->set_page_body(
Condition0%0/2
$globals->pref($PKEY_MSG_NEW_HEAD) || "<h1>@{[$globals->page_title];}</h1>\n\n<p>This form is provided as an easy way for you to give feedback \nconcerning this web site, and at the same time, let everyone else \nknow what you think.</p>\n"
l!l
00
MC/DC0%0/1
$globals->pref($PKEY_MSG_NEW_HEAD) || "<h1>@{[$globals->page_title];}</h1>\n\n<p>This form is provided as an easy way for you to give feedback \nconcerning this web site, and at the same time, let everyone else \nknow what you think.</p>\n"
$globals->pref($PKEY_MSG_NEW_HEAD)
Truth table0%0/2
A
A= $globals->pref($PKEY_MSG_NEW_HEAD)
Aresult
11
00
578 $globals->pref( $PKEY_MSG_NEW_HEAD ) || <<__endquote );
579 0 <h1>@{[$globals->page_title()]}</h1>
580  
581 <p>This form is provided as an easy way for you to give feedback
582 concerning this web site, and at the same time, let everyone else
583 know what you think.</p>
584 __endquote
585  
586 0 $globals->append_page_body( <<__endquote );
587 0 <p>The fields indicated with a '@{[$form->required_field_marker()]}'
588 are required.</p>
589  
590 0 @{$form->make_html_input_form( 1, 1 )}
591  
592 <p>It may take from 1 to 30 seconds to process this form, so please be
593 patient and don't click Send multiple times. A confirmation message
594 will appear if everything worked.</p>
595  
596 <p>You may also <a href="$TOKEN_READ">read</a> the existing messages.</p>
597 __endquote
598 }
599  
600 ######################################################################
601  
602 0 ▶sub invalid_input {
Subroutine invalid_input: not called CC=1 SCAR=6.9
Pod undocumented
603 0 my ($self, $form) = @_;
604 0 my $globals = $self->{$KEY_SITE_GLOBALS};
605  
606 0 $globals->page_title( "Information Missing" );
607  
608 0 $globals->set_page_body( <<__endquote );
609 0 <h1>@{[$globals->page_title()]}</h1>
610  
611 <p>Your submission could not be added to the guest book because some
612 of the fields were not correctly filled in, which are indicated with a
613 0 '@{[$form->bad_input_marker()]}'. Fields with a
614 0 '@{[$form->required_field_marker()]}' are required and can not be left
615 empty. Please make sure you have entered your name and e-mail address
616 correctly, and then try sending it again.</p>
617  
618 0 @{$form->make_html_input_form( 1, 1 )}
619  
620 <p>It may take from 1 to 30 seconds to process this form, so please be
621 patient and don't click Send multiple times. A confirmation message
622 will appear if everything worked.</p>
623  
624 <p>You may also <a href="$TOKEN_READ">read</a> the existing messages.</p>
625 __endquote
626 }
627  
628 ######################################################################
629  
630 0 ▶sub send_mail_to_me {
Subroutine send_mail_to_me: not called CC=4 SCAR=30.0
Pod undocumented
631 0 my ($self, $form) = @_;
632 0 my $globals = $self->{$KEY_SITE_GLOBALS};
633  
634 0 ▶ my $err_msg = $self->send_email_message(
Condition0%0/2
$globals->pref($PKEY_EMAIL_SUBJ) || $globals->default_application_title . ' -- GuestBook Message'
l!l
00
MC/DC0%0/1
$globals->pref($PKEY_EMAIL_SUBJ) || $globals->default_application_title . ' -- GuestBook Message'
$globals->pref($PKEY_EMAIL_SUBJ)
Truth table0%0/2
A
A= $globals->pref($PKEY_EMAIL_SUBJ)
Aresult
11
00
635 $globals->default_maintainer_name(),
636 $globals->default_maintainer_email_address(),
637 $globals->user_post_param( $FFN_NAMEREAL ),
638 $globals->user_post_param( $FFN_EMAIL ),
639 $globals->pref( $PKEY_EMAIL_SUBJ ) ||
640 $globals->default_application_title().' -- GuestBook Message',
641 $form->make_text_input_echo( 0, $EMPTY_FIELD_ECHO_STRING ),
642 <<__endquote.
643 It is the result of a form submission from a site visitor,
644 0 "@{[$globals->user_post_param( $FFN_NAMEREAL )]}" <@{[$globals->user_post_param( $FFN_EMAIL )]}>.
645 0 ▶From: @{[$globals->client_ip()]} @{[$globals->client_domain()]}.
Branch: 1 branch
BranchTrueFalseTotal
$globals->user_post_param($FFN_WANTCOPY) ? : 0 0 0
646 __endquote
647 ($globals->user_post_param( $FFN_WANTCOPY ) ?
648 "The visitor also requested a copy be sent to them.\n" :
649 "The visitor did not request a copy be sent to them.\n"),
650 );
651  
652 0 ▶ if( $err_msg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err_msg) 0 0 0
653 0 $globals->add_error( $err_msg );
654
655 0 $globals->page_title( "Error Sending Mail" );
656  
657 0 $globals->set_page_body( <<__endquote );
658 0 <h1>@{[$globals->page_title()]}</h1>
659  
660 <p>I'm sorry, but an error has occurred while trying to e-mail your
661 message to me. It also hasn't been added to the guest book. As a
662 result, no one will see it.</p>
663  
664 <p>This problem can occur if you enter a nonexistant or unreachable
665 e-mail address into the e-mail field, in which case, please enter a
666 working e-mail address and try clicking 'Send' again. You can check
667 if that is the problem by checking the following error string:</p>
668  
669 <p>$err_msg</p>
670  
671 0 @{[$self->get_amendment_message()]}
672  
673 0 @{$form->make_html_input_form( 1, 1 )}
674  
675 <p>It may take from 1 to 30 seconds to process this form, so please be
676 patient and don't click Send multiple times. A confirmation message
677 will appear if everything worked.</p>
678  
679 <p>You may also <a href="$TOKEN_READ">read</a> the existing messages.</p>
680 __endquote
681  
682 0 $globals->add_no_error();
683 0 return( 0 );
684 }
685
686 0 return( 1 );
687 }
688  
689 ######################################################################
690  
691 0 ▶sub sign_guest_book {
Subroutine sign_guest_book: not called CC=2 SCAR=17.9
Pod undocumented
692 0 my ($self, $form) = @_;
693 0 my $globals = $self->{$KEY_SITE_GLOBALS};
694  
695 0 my $new_posting = $globals->user_post();
696 0 $new_posting->store( $LFN_SUBMIT_DATE, $self->today_date_utc() );
697 0 $new_posting->store( $LFN_SUBMIT_DOMAIN,
698 $globals->client_ip().':'.$globals->client_domain() );
699  
700 0 my $filename = $globals->pref( $PKEY_FN_MESSAGES );
701 0 $self->append_new_records( $filename, $new_posting );
702  
703 0 ▶ if( my $err_msg = $globals->get_error() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err_msg = $globals->get_error) 0 0 0
704 0 $globals->add_error( $err_msg );
705
706 0 $globals->page_title( "Error Writing to Guest Book" );
707  
708 0 $globals->set_page_body( <<__endquote );
709 0 <h1>@{[$globals->page_title()]}</h1>
710  
711 <p>I'm sorry, but an error has occurred while trying to write your
712 message into the guest book. As a result it will not appear when
713 the guest book is viewed by others. However, the message was
714 e-mailed to me.</p>
715  
716 <p>details: $err_msg</p>
717  
718 0 @{[$self->get_amendment_message()]}
719  
720 0 @{$form->make_html_input_form( 1, 1 )}
721  
722 <p>It may take from 1 to 30 seconds to process this form, so please be
723 patient and don't click Send multiple times. A confirmation message
724 will appear if everything worked.</p>
725  
726 <p>You may also <a href="$TOKEN_READ">read</a> the existing messages.</p>
727 __endquote
728  
729 0 $globals->add_no_error();
730 0 return( 0 );
731 }
732
733 0 return( 1 );
734 }
735  
736 ######################################################################
737  
738 0 ▶sub mail_me_and_sign_guest_ok {
Subroutine mail_me_and_sign_guest_ok: not called CC=2 SCAR=17.9
Pod undocumented
739 0 my ($self, $form) = @_;
740 0 my $globals = $self->{$KEY_SITE_GLOBALS};
741  
742 0 $globals->page_title( "Your Message Has Been Added" );
743  
744 0 $globals->set_page_body( <<__endquote );
745 0 <h1>@{[$globals->page_title()]}</h1>
746  
747 <p>Your message has been added to this guest book, and a copy was
748 e-mailed to me as well. This is what the copy e-mailed to me said:</p>
749  
750 <p><strong>To:</strong>
751 0 @{[$globals->default_maintainer_name()]}
752 0 &lt;@{[$globals->default_maintainer_email_address()]}&gt;
753 <br /><strong>From:</strong>
754 0 @{[$globals->user_post_param( $FFN_NAMEREAL )]}
755 0 &lt;@{[$globals->user_post_param( $FFN_EMAIL )]}&gt;
756 <br /><strong>Subject:</strong>
757 0 ▶@{[$globals->pref( $PKEY_EMAIL_SUBJ ) ||
Condition0%0/2
$globals->pref($PKEY_EMAIL_SUBJ) || $globals->default_application_title . ' -- GuestBook Message'
l!l
00
MC/DC0%0/1
$globals->pref($PKEY_EMAIL_SUBJ) || $globals->default_application_title . ' -- GuestBook Message'
$globals->pref($PKEY_EMAIL_SUBJ)
Truth table0%0/2
A
A= $globals->pref($PKEY_EMAIL_SUBJ)
Aresult
11
00
758 $globals->default_application_title().' -- GuestBook Message']}</p>
759  
760 0 @{[$form->make_html_input_echo( 1, 1, $EMPTY_FIELD_ECHO_STRING )]}
761  
762 <p>You may also <a href="$TOKEN_READ">read</a> the existing messages.</p>
763 __endquote
764 }
765  
766 ######################################################################
767  
768 0 ▶sub send_mail_to_writer {
Subroutine send_mail_to_writer: not called CC=3 SCAR=24.8
Pod undocumented
769 0 my ($self, $form) = @_;
770 0 my $globals = $self->{$KEY_SITE_GLOBALS};
771  
772 0 ▶ my $err_msg = $self->send_email_message(
Condition0%0/2
$globals->pref($PKEY_EMAIL_SUBJ) || $globals->default_application_title . ' -- GuestBook Message'
l!l
00
MC/DC0%0/1
$globals->pref($PKEY_EMAIL_SUBJ) || $globals->default_application_title . ' -- GuestBook Message'
$globals->pref($PKEY_EMAIL_SUBJ)
Truth table0%0/2
A
A= $globals->pref($PKEY_EMAIL_SUBJ)
Aresult
11
00
773 $globals->user_post_param( $FFN_NAMEREAL ),
774 $globals->user_post_param( $FFN_EMAIL ),
775 $globals->default_maintainer_name(),
776 $globals->default_maintainer_email_address(),
777 $globals->pref( $PKEY_EMAIL_SUBJ ) ||
778 $globals->default_application_title().' -- GuestBook Message',
779 $form->make_text_input_echo( 0, $EMPTY_FIELD_ECHO_STRING ),
780 <<__endquote,
781 It is the result of a form submission from a site visitor,
782 0 "@{[$globals->user_post_param( $FFN_NAMEREAL )]}" <@{[$globals->user_post_param( $FFN_EMAIL )]}>.
783 0 From: @{[$globals->client_ip()]} @{[$globals->client_domain()]}.
784 __endquote
785 );
786  
787 0 ▶ if( $err_msg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err_msg) { } 0 0 0
788 0 $globals->add_error( $err_msg );
789 0 $globals->append_page_body( <<__endquote );
790 <p>However, something went wrong when trying to send you a copy:
791 $err_msg.</p>
792 __endquote
793 0 $globals->add_no_error();
794  
795 } else {
796 0 $globals->append_page_body( <<__endquote );
797 <p>Also, a copy was successfully sent to you at
798 0 '@{[$globals->user_post_param( $FFN_EMAIL )]}'.</p>
799 __endquote
800 }
801 }
802  
803 ######################################################################
804  
805 0 ▶sub fetch_all_records {
Subroutine fetch_all_records: not called CC=6 SCAR=37.4
Pod undocumented
806 0 my ($self, $filename, $read_and_write) = @_;
807 0 my $globals = $self->{$KEY_SITE_GLOBALS};
808
809 0 my $fh = gensym;
810
811 0 ▶ $self->open_and_lock( $fh, $filename, $read_and_write ) or return( undef );
Branch: 1 branch
BranchTrueFalseTotal
$self->open_and_lock($fh, $filename, $read_and_write) or return undef 0 0 0
812  
813 0 ▶ seek( $fh, 0, 0 ) or do {
Branch: 1 branch
BranchTrueFalseTotal
seek $fh, 0, 0 or do { $globals->add_virtual_filename_error("seek start of", $filename); return undef } 0 0 0
814 0 $globals->add_virtual_filename_error( "seek start of", $filename );
815 0 return( undef );
816 };
817  
818 0 ▶ my $ra_record_list = CGI::MultiValuedHash->batch_from_file( $fh, 1 ) or do {
Branch: 1 branch
BranchTrueFalseTotal
my $ra_record_list = "CGI::MultiValuedHash"->batch_from_file($fh, 1) or do { $globals->add_virtual_filename_error("read record from", $filename); return undef } 0 0 0
819 0 $globals->add_virtual_filename_error( "read record from", $filename );
820 0 return( undef );
821 };
822  
823 0 ▶ $self->unlock_and_close( $fh, $filename ) or return( undef );
Branch: 1 branch
BranchTrueFalseTotal
$self->unlock_and_close($fh, $filename) or return undef 0 0 0
824  
825 0 ▶ return( wantarray ? @{$ra_record_list} : $ra_record_list );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
826 }
827  
828 ######################################################################
829  
830 0 ▶sub append_new_records {
Subroutine append_new_records: not called CC=6 SCAR=37.4
Pod undocumented
831 0 my $self = shift( @_ );
832 0 my $filename = shift( @_ );
833 0 ▶ my $ra_record_list = (ref( $_[0] ) eq 'ARRAY') ? $_[0] : [@_];
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
834 0 my $globals = $self->{$KEY_SITE_GLOBALS};
835
836 0 my $fh = gensym;
837
838 0 ▶ $self->open_and_lock( $fh, $filename, 1 ) or return( undef );
Branch: 1 branch
BranchTrueFalseTotal
$self->open_and_lock($fh, $filename, 1) or return undef 0 0 0
839  
840 0 ▶ seek( $fh, 0, 2 ) or do {
Branch: 1 branch
BranchTrueFalseTotal
seek $fh, 0, 2 or do { $globals->add_virtual_filename_error("seek end of", $filename); return undef } 0 0 0
841 0 $globals->add_virtual_filename_error( "seek end of", $filename );
842 0 return( undef );
843 };
844  
845 0 ▶ CGI::MultiValuedHash->batch_to_file( $fh, $ra_record_list ) or do {
Branch: 1 branch
BranchTrueFalseTotal
"CGI::MultiValuedHash"->batch_to_file($fh, $ra_record_list) or do { $globals->add_virtual_filename_error("write record to", $filename); return undef } 0 0 0
846 0 $globals->add_virtual_filename_error( "write record to", $filename );
847 0 return( undef );
848 };
849  
850 0 ▶ $self->unlock_and_close( $fh, $filename ) or return( undef );
Branch: 1 branch
BranchTrueFalseTotal
$self->unlock_and_close($fh, $filename) or return undef 0 0 0
851  
852 0 return( 1 );
853 }
854  
855 ######################################################################
856  
857 0 ▶sub open_and_lock {
Subroutine open_and_lock: not called CC=5 SCAR=34.0
Pod undocumented
858 0 my ($self, $fh, $filename, $read_and_write) = @_;
859 0 my $globals = $self->{$KEY_SITE_GLOBALS};
860
861 0 my $physical_path = $globals->physical_filename( $filename );
862 0 ▶ my $flags = $read_and_write ? O_RDWR|O_CREAT : O_RDONLY;
Branch: 1 branch
BranchTrueFalseTotal
$read_and_write ? : 0 0 0
863 0 my $perms = 0666;
864  
865 0 ▶ sysopen( $fh, $physical_path, $flags, $perms ) or do {
Branch: 1 branch
BranchTrueFalseTotal
sysopen $fh, $physical_path, $flags, $perms or do { $globals->add_virtual_filename_error("open", $filename); return undef } 0 0 0
866 0 $globals->add_virtual_filename_error( "open", $filename );
867 0 return( undef );
868 };
869  
870 0 ▶ flock( $fh, $read_and_write ? LOCK_EX : LOCK_SH ) or do {
Branch: 2 branches
BranchTrueFalseTotal
flock $fh, $read_and_write ? 2 : 1 or do { $globals->add_virtual_filename_error("lock", $filename); return undef } 0 0 0
$read_and_write ? : 0 0 0
871 0 $globals->add_virtual_filename_error( "lock", $filename );
872 0 return( undef );
873 };
874  
875 0 return( 1 );
876 }
877  
878 ######################################################################
879  
880 0 ▶sub unlock_and_close {
Subroutine unlock_and_close: not called CC=3 SCAR=24.8
Pod undocumented
881 0 my ($self, $fh, $filename) = @_;
882 0 my $globals = $self->{$KEY_SITE_GLOBALS};
883
884 0 ▶ flock( $fh, LOCK_UN ) or do {
Branch: 1 branch
BranchTrueFalseTotal
flock $fh, 8 or do { $globals->add_virtual_filename_error("unlock", $filename); return undef } 0 0 0
885 0 $globals->add_virtual_filename_error( "unlock", $filename );
886 0 return( undef );
887 };
888  
889 0 ▶ close( $fh ) or do {
Branch: 1 branch
BranchTrueFalseTotal
close $fh or do { $globals->add_virtual_filename_error("close", $filename); return undef } 0 0 0
890 0 $globals->add_virtual_filename_error( "close", $filename );
891 0 return( undef );
892 };
893  
894 0 return( 1 );
895 }
896  
897 ######################################################################
898  
899 0 ▶sub send_email_message {
Subroutine send_email_message: not called CC=9 SCAR=45.0
Pod undocumented
900 0 my ($self, $to_name, $to_email, $from_name, $from_email,
901 $subject, $body, $body_head_addition) = @_;
902 0 my $globals = $self->{$KEY_SITE_GLOBALS};
903  
904 0 my $EMAIL_HEADER_STRIP_PATTERN = '[,<>()"\'\n]'; #for names and addys
905 0 $to_name =~ s/$EMAIL_HEADER_STRIP_PATTERN//g;
906 0 $to_email =~ s/$EMAIL_HEADER_STRIP_PATTERN//g;
907 0 $from_name =~ s/$EMAIL_HEADER_STRIP_PATTERN//g;
908 0 $from_email =~ s/$EMAIL_HEADER_STRIP_PATTERN//g;
909 0 ▶ $globals->is_debug() and $subject .= " -- debug";
Branch: 1 branch
BranchTrueFalseTotal
$globals->is_debug and $subject .= ' -- debug' 0 0 0
910
911 0 my $body_header = <<__endquote.
912 --------------------------------------------------
913 0 This e-mail was sent at @{[$self->today_date_utc()]}
914 0 by the web site "@{[$globals->default_application_title()]}",
915 0 ▶which is located at "@{[$globals->url_base()]}".
Branch: 1 branch
BranchTrueFalseTotal
$globals->is_debug ? : 0 0 0
916 __endquote
917 $body_head_addition.
918 ($globals->is_debug() ? "Debugging is currently turned on.\n" :
919 '').<<__endquote;
920 --------------------------------------------------
921 __endquote
922  
923 0 my $body_footer = <<__endquote;
924  
925  
926 --------------------------------------------------
927 END OF MESSAGE
928 __endquote
929
930 0 my $host = $globals->default_smtp_host();
931 0 my $timeout = $globals->default_smtp_timeout();
932 0 my $error_msg = '';
933  
934 TRY: {
935 0 my $smtp;
936  
937 0 eval { require Net::SMTP; };
938 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
939 0 $error_msg = "can't open program module 'Net::SMTP'";
940 0 last TRY;
941 }
942
943 0 ▶ unless( $smtp = Net::SMTP->new( $host, Timeout => $timeout ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($smtp = "Net::SMTP"->new($host, "Timeout", $timeout)) 0 0 0
944 0 $error_msg = "can't connect to smtp host: $host";
945 0 last TRY;
946 }
947  
948 0 ▶ unless( $smtp->verify( $from_email ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($smtp->verify($from_email)) 0 0 0
949 0 $error_msg = "invalid address: @{[$smtp->message()]}";
950 0 last TRY;
951 }
952  
953 0 ▶ unless( $smtp->verify( $to_email ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($smtp->verify($to_email)) 0 0 0
954 0 $error_msg = "invalid address: @{[$smtp->message()]}";
955 0 last TRY;
956 }
957  
958 0 ▶ unless( $smtp->mail( "$from_name <$from_email>" ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($smtp->mail("$from_name <$from_email>")) 0 0 0
959 0 $error_msg = "from: @{[$smtp->message()]}";
960 0 last TRY;
961 }
962  
963 0 ▶ unless( $smtp->to( "$to_name <$to_email>" ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($smtp->to("$to_name <$to_email>")) 0 0 0
964 0 $error_msg = "to: @{[$smtp->message()]}";
965 0 last TRY;
966 }
967  
968 0 $smtp->data( <<__endquote );
969 From: $from_name <$from_email>
970 To: $to_name <$to_email>
971 Subject: $subject
972 Content-Type: text/plain; charset=us-ascii
973  
974 $body_header
975 $body
976 $body_footer
977 __endquote
978  
979 0 $smtp->quit();
980 }
981
982 0 return( $error_msg );
983 }
984  
985 ######################################################################
986  
987 0 ▶sub today_date_utc {
Subroutine today_date_utc: not called CC=1 SCAR=6.9
Pod undocumented
988 0 my ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
989 0 $year += 1900; # year counts from 1900 AD otherwise
990 0 $mon += 1; # ensure January is 1, not 0
991 0 my @parts = ($year, $mon, $mday, $hour, $min, $sec);
992 0 return( sprintf( "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d UTC", @parts ) );
993 }
994  
995 ######################################################################
996  
997 0 ▶sub get_amendment_message {
Subroutine get_amendment_message: not called CC=1 SCAR=6.9
Pod undocumented
998 0 my ($self) = shift( @_ );
999 0 my $globals = $self->{$KEY_SITE_GLOBALS};
1000 0 return( <<__endquote );
1001 <p>This should be temporary, the result of a transient server problem or an
1002 0 update being performed at the moment. Click @{[$globals->recall_html('here')]}
1003 to automatically try again. If the problem persists, please try again later,
1004 0 or send an @{[$globals->maintainer_email_html('e-mail')]} message about the
1005 problem, so it can be fixed.</p>
1006 __endquote
1007 }
1008  
1009 ######################################################################
1010  
1011 1 1;
1012 __END__
« CGI/Portable/AppStatic.pm ↑ Summary DemoMailForm.pm »