s/create/new/g; and use fields('table_name')
[freeside.git] / htdocs / edit / process / svc_domain.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_domain.cgi,v 1.3 1999-01-18 22:48:02 ivan Exp $
4 #
5 # Usage: post form to:
6 #        http://server.name/path/svc_domain.cgi
7 #
8 # Note: Should br run setuid root as user nobody.
9 #
10 # lots of yucky stuff in this one... bleachlkjhui!
11 #
12 # ivan@voicenet.com 97-jan-6
13 #
14 # kludged for new domain template 3.5
15 # ivan@voicenet.com 97-jul-24
16 #
17 # moved internic bits to svc_domain.pm ivan@sisd.com 98-mar-14
18 #
19 # Changes to allow page to work at a relative position in server
20 #       bmccane@maxbaud.net     98-apr-3
21 #
22 # $Log: svc_domain.cgi,v $
23 # Revision 1.3  1999-01-18 22:48:02  ivan
24 # s/create/new/g; and use fields('table_name')
25 #
26 # Revision 1.2  1998/12/17 08:40:30  ivan
27 # s/CGI::Request/CGI.pm/; etc
28 #
29
30 use strict;
31 use CGI;
32 use CGI::Carp qw(fatalsToBrowser);
33 use FS::UID qw(cgisuidsetup);
34 use FS::Record qw(qsearchs);
35 use FS::svc_domain;
36
37 #remove this to actually test the domains!
38 $FS::svc_domain::whois_hack = 1;
39
40 my($cgi) = new CGI;
41 &cgisuidsetup($cgi);
42
43 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
44 my($svcnum)=$1;
45
46 my($new) = new FS::svc_domain ( {
47   map {
48     $_, scalar($cgi->param($_));
49   #} qw(svcnum pkgnum svcpart domain action purpose)
50   } ( fields('svc_domain'), qw( pkgnum svcpart action purpose ) )
51 } );
52
53 my($error);
54 if ($cgi->param('legal') ne "Yes") {
55   $error = "Customer did not agree to be bound by NSI's ".
56     qq!<A HREF="http://rs.internic.net/help/agreement.txt">!.
57     "Domain Name Resgistration Agreement</A>";
58 } elsif ($cgi->param('svcnum')) {
59   $error="Can't modify a domain!";
60 } else {
61   $error=$new->insert;
62   $svcnum=$new->svcnum;
63 }
64
65 unless ($error) {
66   print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum");
67 } else {
68   idiot($error);
69 }
70