source: branches/htmlform/cgi-bin/CommonWeb.pm@ 487

Last change on this file since 487 was 480, checked in by Kris Deugau, 14 years ago

/branches/htmlform

Forgot to remove some refs to printHeader in CommonWeb.pm in r479 (see #15, #26)
Add the Invitable Forgotten New File (DB error template)

File size: 1.4 KB
RevLine 
[8]1# ipdb/cgi-bin/CommonWeb.pm
2###
3# SVN revision info
4# $Date$
5# SVN revision $Rev$
6# Last update by $Author$
7###
8
[4]9package CommonWeb;
10
11use strict;
12use warnings;
13use Exporter;
14use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
15
16$VERSION = 1.00;
17@ISA = qw(Exporter);
[479]18@EXPORT_OK = qw( &printError &printAndExit &desanitize &cleanInput &desanitize);
[4]19
20@EXPORT = (); #export nothing by default
[480]21%EXPORT_TAGS = ( ALL => [qw( &printError &printAndExit &desanitize &cleanInput )],
22 lean => [qw( &printError &printAndExit &cleanInput )]
[4]23 );
24
25
26sub printError($)
27{
28 my $errStr = $_[0];
29 print qq(
[105]30 <center><p class="regular"> $errStr </p>
31 <input type="button" value="Back" onclick="history.go(-1)">
32 </center>
[4]33 );
34}
35
36sub printAndExit($)
37{
38 my $errStr = $_[0];
39 print qq(
40 <center><p class="regular"> $errStr </p>
41 <input type="button" value="Back" onclick="history.go(-1)">
42 </center>
43 );
[450]44 print "<br>would print footer but already dun gone and shot(self->foot)\n";
[4]45 exit(0);
46}
47
48# needs a reference to the webvar hash.
49# takes out backticks and single quotes
50sub cleanInput($)
51{
52 my $hashRef = $_[0];
53
54 foreach my $key (keys %$hashRef)
55 {
56 $hashRef->{$key} =~ s/`/\\`/g;
57 $hashRef->{$key} =~ s/'/\'/g;
58 }
59}
60
61# undoes clean input. takes a string as an arg.
62sub desanitize($)
63{
64 my $string = $_[0];
65 $string =~ s/\\`/`/g;
66 $string =~ s/\\'/'/g;
67 return $string;
68}
69
70# indicate that the module loaded okay.
711;
Note: See TracBrowser for help on using the repository browser.