more mod_perl fixes, and bugfixes Peter Wemm sent via email
[freeside.git] / htdocs / edit / process / svc_domain.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_domain.cgi,v 1.5 1999-02-07 09:59:33 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.5  1999-02-07 09:59:33  ivan
24 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
25 #
26 # Revision 1.4  1999/01/19 05:14:01  ivan
27 # for mod_perl: no more top-level my() variables; use vars instead
28 # also the last s/create/new/;
29 #
30 # Revision 1.3  1999/01/18 22:48:02  ivan
31 # s/create/new/g; and use fields('table_name')
32 #
33 # Revision 1.2  1998/12/17 08:40:30  ivan
34 # s/CGI::Request/CGI.pm/; etc
35 #
36
37 use strict;
38 use vars qw( $cgi $svcnum $new $error );
39 use CGI;
40 use CGI::Carp qw(fatalsToBrowser);
41 use FS::UID qw(cgisuidsetup);
42 use FS::Record qw(qsearchs fields);
43 use FS::svc_domain;
44 use FS::CGI qw(popurl);
45
46 #remove this to actually test the domains!
47 $FS::svc_domain::whois_hack = 1;
48
49 $cgi = new CGI;
50 &cgisuidsetup($cgi);
51
52 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
53 $svcnum = $1;
54
55 $new = new FS::svc_domain ( {
56   map {
57     $_, scalar($cgi->param($_));
58   #} qw(svcnum pkgnum svcpart domain action purpose)
59   } ( fields('svc_domain'), qw( pkgnum svcpart action purpose ) )
60 } );
61
62 if ($cgi->param('legal') ne "Yes") {
63   $error = "Customer did not agree to be bound by NSI's ".
64     qq!<A HREF="http://rs.internic.net/help/agreement.txt">!.
65     "Domain Name Resgistration Agreement</A>";
66 } elsif ($cgi->param('svcnum')) {
67   $error="Can't modify a domain!";
68 } else {
69   $error=$new->insert;
70   $svcnum=$new->svcnum;
71 }
72
73 if ($error) {
74   $cgi->param('error', $error);
75   print $cgi->redirect(popurl(2). "svc_domain.cgi?". $cgi->query_string );
76 } else {
77   print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum");
78 }
79