3 # $Id: svc_acct_sm.cgi,v 1.10 1999-07-20 06:03:36 ivan Exp $
6 # http://server.name/path/svc_domain.cgi
8 # ivan@voicenet.com 96-mar-5
10 # need to look at table in results to make it more readable
14 # rewrite ivan@sisd.com 98-mar-15
16 # Changes to allow page to work at a relative position in server
17 # bmccane@maxbaud.net 98-apr-3
19 # $Log: svc_acct_sm.cgi,v $
20 # Revision 1.10 1999-07-20 06:03:36 ivan
21 # s/CGI::Request/CGI/; (how'd i miss that before?)
23 # Revision 1.9 1999/04/09 04:22:34 ivan
26 # Revision 1.8 1999/04/09 03:52:55 ivan
27 # explicit & for table/itable/ntable
29 # Revision 1.7 1999/02/28 00:03:56 ivan
30 # removed misleading comments
32 # Revision 1.6 1999/02/09 09:22:58 ivan
35 # Revision 1.5 1999/01/19 05:14:16 ivan
36 # for mod_perl: no more top-level my() variables; use vars instead
37 # also the last s/create/new/;
39 # Revision 1.4 1999/01/18 09:41:40 ivan
40 # all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
43 # Revision 1.3 1998/12/17 09:41:11 ivan
44 # s/CGI::(Base|Request)/CGI.pm/;
48 use vars qw( $conf $cgi $mydomain $domuser $svc_domain $domsvc @svc_acct_sm );
50 use CGI::Carp qw(fatalsToBrowser);
51 use FS::UID qw(cgisuidsetup);
52 use FS::CGI qw(popurl idiot header table);
53 use FS::Record qw(qsearch qsearchs);
63 $mydomain = $conf->config('domain');
65 $cgi->param('domuser') =~ /^([a-z0-9_\-]{0,32})$/;
68 $cgi->param('domain') =~ /^([\w\-\.]+)$/ or die "Illegal domain";
69 $svc_domain = qsearchs('svc_domain',{'domain'=>$1})
70 or die "Unknown domain";
71 $domsvc = $svc_domain->svcnum;
74 @svc_acct_sm=qsearch('svc_acct_sm',{
75 'domuser' => $domuser,
79 @svc_acct_sm=qsearch('svc_acct_sm',{'domsvc' => $domsvc});
82 if ( scalar(@svc_acct_sm) == 1 ) {
83 my($svcnum)=$svc_acct_sm[0]->svcnum;
84 print $cgi->redirect(popurl(2). "view/svc_acct_sm.cgi?$svcnum");
85 } elsif ( scalar(@svc_acct_sm) > 1 ) {
86 print $cgi->header( '-expires' => 'now' ),
87 header('Mail Alias Search Results'),
90 <TH>Mail to<BR><FONT SIZE=-1>(click to view mail alias)</FONT></TH>
91 <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
96 foreach $svc_acct_sm (@svc_acct_sm) {
97 my($svcnum,$domuser,$domuid,$domsvc)=(
99 $svc_acct_sm->domuser,
100 $svc_acct_sm->domuid,
101 $svc_acct_sm->domsvc,
104 my $svc_domain = qsearchs( 'svc_domain', { 'svcnum' => $domsvc } );
106 my $domain = $svc_domain->domain;
108 print qq!<TR><TD><A HREF="!. popurl(2). qq!view/svc_acct_sm.cgi?$svcnum">!,
109 #print '', ( ($domuser eq '*') ? "<I>(anything)</I>" : $domuser );
110 ( ($domuser eq '*') ? "<I>(anything)</I>" : $domuser ),
111 qq!\@$domain</A> </TD>!,
114 my $warning = "couldn't find svc_domain.svcnum $svcnum ( svc_acct_sm.svcnum $svcnum";
116 print "<TR><TD>WARNING: $warning</TD>";
119 my $svc_acct = qsearchs( 'svc_acct', { 'uid' => $domuid } );
121 my $username = $svc_acct->username;
122 my $svc_acct_svcnum =$svc_acct->svcnum;
123 print qq!<TD><A HREF="!, popurl(2),
124 qq!view/svc_acct.cgi?$svc_acct_svcnum">$username\@$mydomain</A>!,
128 my $warning = "couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum $svcnum)!";
130 print "<TD>WARNING: $warning</TD></TR>";
135 print '</TABLE></BODY></HTML>';
138 idiot("Mail Alias not found");