1 |
slords |
1.1 |
diff -ruN e-smith-hosts-2.2.0.a/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries e-smith-hosts-2.2.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries |
2 |
|
|
--- e-smith-hosts-2.2.0.a/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries 2010-09-26 12:02:31.000000000 -0600 |
3 |
|
|
+++ e-smith-hosts-2.2.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/hostentries 2008-10-07 11:35:50.000000000 -0600 |
4 |
|
|
@@ -267,4 +267,8 @@ |
5 |
|
|
<trans>Error: This IP address is not on any of our local |
6 |
|
|
networks.</trans> |
7 |
|
|
</entry> |
8 |
|
|
+ <entry> |
9 |
|
|
+ <base>MUST_BE_VALID_HOSTNAME_OR_IP</base> |
10 |
|
|
+ <trans>Must be a valid hostname or IP number</trans> |
11 |
|
|
+ </entry> |
12 |
|
|
</lexicon> |
13 |
|
|
diff -up e-smith-hosts-2.2.0/root/etc/e-smith/web/functions/hostentries.host_ip_validator e-smith-hosts-2.2.0/root/etc/e-smith/web/functions/hostentries |
14 |
|
|
--- e-smith-hosts-2.2.0/root/etc/e-smith/web/functions/hostentries.host_ip_validator 2010-09-26 12:06:12.000000000 -0600 |
15 |
|
|
+++ e-smith-hosts-2.2.0/root/etc/e-smith/web/functions/hostentries 2010-09-26 12:06:35.000000000 -0600 |
16 |
|
|
@@ -122,7 +122,7 @@ |
17 |
|
|
</page> |
18 |
|
|
<page name="Remote" pre-event="turn_off_buttons()" post-event="goto_confirm()"> |
19 |
|
|
<description>REMOTE_PAGE_DESCRIPTION</description> |
20 |
|
|
- <field type="text" id="global_ip"> |
21 |
|
|
+ <field type="text" id="global_ip" validation="hostname_or_ip"> |
22 |
|
|
<label>IP_ADDRESS</label> |
23 |
|
|
</field> |
24 |
|
|
<subroutine src="print_button('NEXT')" /> |
25 |
|
|
diff -up e-smith-hosts-2.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/hostentries.pm.host_ip_validator e-smith-hosts-2.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/hostentries.pm |
26 |
|
|
--- e-smith-hosts-2.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/hostentries.pm.host_ip_validator 2008-10-07 11:35:50.000000000 -0600 |
27 |
|
|
+++ e-smith-hosts-2.2.0/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/hostentries.pm 2010-09-26 12:01:45.000000000 -0600 |
28 |
|
|
@@ -52,6 +52,7 @@ our @EXPORT = qw( |
29 |
|
|
print_save_or_add_button |
30 |
|
|
not_taken |
31 |
|
|
must_be_local |
32 |
|
|
+ hostname_or_ip |
33 |
|
|
); |
34 |
|
|
|
35 |
|
|
our $VERSION = sprintf '%d.%03d', q$Revision: 1.54 $ =~ /: (\d+).(\d+)/; |
36 |
|
|
@@ -103,6 +104,48 @@ sub new |
37 |
|
|
return $self; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
+=head2 hostname_or_ip |
41 |
|
|
+ |
42 |
|
|
+Validation routine for the remote address field for network printers. |
43 |
|
|
+ |
44 |
|
|
+=for testing |
45 |
|
|
+my $fm = esmith::FormMagick::Panel::hostentries->new(); |
46 |
|
|
+can_ok('main', 'hostname_or_ip'); |
47 |
|
|
+can_ok('CGI::FormMagick::Validator', 'ip_number'); |
48 |
|
|
+isnt(CGI::FormMagick::Validator::ip_number($fm, '1.2.3'), "OK", "ip_number works OK"); |
49 |
|
|
+like(CGI::FormMagick::Validator::ip_number($fm, '1.2.3'), qr(enough octets), "ip_number works OK"); |
50 |
|
|
+foreach ("1.2.3.4", "255.255.255.255", "foo.com", "foo.bar.com", "123.foo.xxx"){ |
51 |
|
|
+ is(hostname_or_ip($fm, $_), "OK", "$_ should be OK"); |
52 |
|
|
+} |
53 |
|
|
+foreach ("1.2.3", "foo bar", "foo;bar;com", " ", undef) { |
54 |
|
|
+ isnt(hostname_or_ip($fm, $_), "OK", "$_ should not be OK"); |
55 |
|
|
+} |
56 |
|
|
+ |
57 |
|
|
+=cut |
58 |
|
|
+ |
59 |
|
|
+sub hostname_or_ip |
60 |
|
|
+{ |
61 |
|
|
+ my ($fm, $data) = @_; |
62 |
|
|
+ if ($data =~ /^[\d\.]+$/) { |
63 |
|
|
+ if (CGI::FormMagick::Validator::ip_number($fm, $data) eq "OK") |
64 |
|
|
+ { |
65 |
|
|
+ return "OK"; |
66 |
|
|
+ } |
67 |
|
|
+ else |
68 |
|
|
+ { |
69 |
|
|
+ return "MUST_BE_VALID_HOSTNAME_OR_IP"; |
70 |
|
|
+ } |
71 |
|
|
+ } |
72 |
|
|
+ elsif ($data =~ /^([a-zA-Z0-9\.\-]+)$/ ) |
73 |
|
|
+ { |
74 |
|
|
+ return "OK"; |
75 |
|
|
+ } |
76 |
|
|
+ else |
77 |
|
|
+ { |
78 |
|
|
+ return "MUST_BE_VALID_HOSTNAME_OR_IP"; |
79 |
|
|
+ } |
80 |
|
|
+} |
81 |
|
|
+ |
82 |
|
|
=head1 HTML GENERATION ROUTINES |
83 |
|
|
|
84 |
|
|
Routines for generating chunks of HTML needed by the panel. |