0d84d7c4e5605b822eb2348acf18976459f82139
[freeside.git] / httemplate / misc / process / catchall.cgi
1 <%
2 #
3 # $Id: catchall.cgi,v 1.1 2001-08-19 15:53:35 jeff Exp $
4 #
5 # Usage: post form to:
6 #        http://server.name/path/catchall.cgi
7 #
8 # $Log: catchall.cgi,v $
9 # Revision 1.1  2001-08-19 15:53:35  jeff
10 # added user interface for svc_forward and vpopmail support
11 #
12 #
13
14 use strict;
15 use vars qw( $cgi $svcnum $old $new $error );
16 use CGI;
17 use CGI::Carp qw(fatalsToBrowser);
18 use FS::UID qw(cgisuidsetup);
19 use FS::Record qw(qsearchs fields);
20 use FS::svc_domain;
21 use FS::CGI qw(popurl);
22
23 $FS::svc_domain::whois_hack=1;
24
25 $cgi = new CGI;
26 cgisuidsetup($cgi);
27
28 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
29 $svcnum =$1;
30
31 $old = qsearchs('svc_domain',{'svcnum'=>$svcnum}) if $svcnum;
32
33 $new = new FS::svc_domain ( {
34   map {
35     ($_, scalar($cgi->param($_)));
36   } ( fields('svc_domain'), qw( pkgnum svcpart ) )
37 } );
38
39 $new->setfield('action' => 'M');
40
41 if ( $svcnum ) {
42   $error = $new->replace($old);
43 } else {
44   $error = $new->insert;
45   $svcnum = $new->getfield('svcnum');
46
47
48 if ($error) {
49   $cgi->param('error', $error);
50   print $cgi->redirect(popurl(2). "catchall.cgi?". $cgi->query_string );
51 } else {
52   print $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum");
53 }
54
55 %>