3 # Create, update or delete a host address
5 require './net-lib.pl';
6 $access{'hosts'} == 2 || &error($text{'hosts_ecannot'});
8 &lock_file($config{'hosts_file'});
9 @hosts = &list_hosts();
12 $host = $hosts[$in{'idx'}];
16 # saving or updating a host
17 $whatfailed = "Failed to save host";
18 &check_ipaddress_any($in{'address'}) ||
19 &error("'$in{'address'}' is not a valid IP address");
20 @h = split(/\s+/, $in{'hosts'});
22 $h =~ /^[A-z0-9\-\.]+$/ ||
23 &error("'$h' is not a valid hostname");
25 @h>0 || &error("You must enter at least one hostname");
28 $host = { 'address' => $in{'address'},
34 $host = $hosts[$in{'idx'}];
35 $host->{'address'} = $in{'address'};
36 $host->{'hosts'} = \@h;
40 &unlock_file($config{'hosts_file'});
41 &webmin_log($in{'delete'} ? 'delete' : $in{'new'} ? 'create' : 'modify',
42 'host', $host->{'address'}, $host);
43 &redirect("list_hosts.cgi");