This commit was manufactured by cvs2svn to create branch 'freeside_import'.
[freeside.git] / htdocs / edit / process / svc_domain.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # process/svc_domain.cgi: Add a domain (process form)
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 use strict;
23 use CGI::Request;
24 use CGI::Carp qw(fatalsToBrowser);
25 use FS::UID qw(cgisuidsetup);
26 use FS::Record qw(qsearchs);
27 use FS::svc_domain;
28
29 #remove this to actually test the domains!
30 $FS::svc_domain::whois_hack = 1;
31
32 my($req) = new CGI::Request;
33 &cgisuidsetup($req->cgi);
34
35 $req->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
36 my($svcnum)=$1;
37
38 my($new) = create FS::svc_domain ( {
39   map {
40     $_, $req->param($_);
41   } qw(svcnum pkgnum svcpart domain action purpose)
42 } );
43
44 my($error);
45 if ($req->param('legal') ne "Yes") {
46   $error = "Customer did not agree to be bound by NSI's ".
47     qq!<A HREF="http://rs.internic.net/help/agreement.txt">!.
48     "Domain Name Resgistration Agreement</A>";
49 } elsif ($req->param('svcnum')) {
50   $error="Can't modify a domain!";
51 } else {
52   $error=$new->insert;
53   $svcnum=$new->svcnum;
54 }
55
56 unless ($error) {
57   $req->cgi->redirect("../../view/svc_domain.cgi?$svcnum");
58 } else {
59   CGI::Base::SendHeaders(); # one guess
60   print <<END;
61 <HTML>
62   <HEAD>
63     <TITLE>Error adding domain</TITLE>
64   </HEAD>
65   <BODY>
66     <CENTER>
67     <H4>Error adding domain</H4>
68     </CENTER>
69     Your update did not occur because of the following error:
70     <P><B>$error</B>
71     <P>Hit the <I>Back</I> button in your web browser, correct this mistake, and submit the form again.
72   </BODY>
73 </HTML>
74 END
75
76 }
77
78