e48878c4262814c39387646255f34703d370b5aa
[freeside.git] / htdocs / view / svc_acct.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: svc_acct.cgi,v 1.2 1998-12-16 05:24:29 ivan Exp $
4 #
5 # Usage: svc_acct.cgi svcnum
6 #        http://server.name/path/svc_acct.cgi?svcnum
7 #
8 # Note: Should be run setuid freeside as user nobody.
9 #
10 # ivan@voicenet.com 96-dec-17
11 #
12 # added link to send info
13 # ivan@voicenet.com 97-jan-4
14 #
15 # added navigation bar and ability to change username, etc.
16 # ivan@voicenet.com 97-jan-30
17 #
18 # activate 800 service
19 # ivan@voicenet.com 97-feb-10
20 #
21 # modified navbar code (should be a subroutine?), added link to cancel account (only if not audited)
22 # ivan@voicenet.com 97-apr-16
23 #
24 # INCOMPLETELY rewrote some things for new API
25 # ivan@voicenet.com 97-jul-29
26 #
27 # FS::Search became FS::Record, use strict, etc. ivan@sisd.com 98-mar-9
28 #
29 # Changes to allow page to work at a relative position in server
30 # Changed 'password' to '_password' because Pg6.3 reserves the password word
31 #       bmccane@maxbaud.net     98-apr-3
32 #
33 # /var/spool/freeside/conf/domain ivan@sisd.com 98-jul-17
34 #
35 # displays arbitrary radius attributes ivan@sisd.com 98-aug-16
36 #
37 # $Log: svc_acct.cgi,v $
38 # Revision 1.2  1998-12-16 05:24:29  ivan
39 # use FS::Conf;
40 #
41
42 use strict;
43 use vars qw($conf);
44 use CGI::Base qw(:DEFAULT :CGI);
45 use CGI::Carp qw(fatalsToBrowser);
46 use FS::UID qw(cgisuidsetup);
47 use FS::Record qw(qsearchs fields);
48 use FS::Conf;
49
50 $conf = new FS::Conf;
51 my $mydomain = $conf->config('domain');
52
53 my($cgi) = new CGI::Base;
54 $cgi->get;
55 &cgisuidsetup($cgi);
56
57 #untaint svcnum
58 $QUERY_STRING =~ /^(\d+)$/;
59 my($svcnum)=$1;
60 my($svc_acct)=qsearchs('svc_acct',{'svcnum'=>$svcnum});
61 die "Unkonwn svcnum" unless $svc_acct;
62
63 my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum});
64 my($pkgnum)=$cust_svc->getfield('pkgnum');
65 my($cust_pkg,$custnum);
66 if ($pkgnum) {
67   $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
68   $custnum=$cust_pkg->getfield('custnum');
69 }
70
71 my($part_svc)=qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
72 die "Unkonwn svcpart" unless $part_svc;
73
74 SendHeaders(); # one guess.
75 print <<END;
76 <HTML>
77   <HEAD>
78     <TITLE>Account View</TITLE>
79   </HEAD>
80   <BODY>
81     <CENTER><H1>Account View</H1>
82     <BASEFONT SIZE=3>
83 <CENTER>
84 END
85
86 if ($pkgnum || $custnum) {
87   print <<END;
88 <A HREF="../view/cust_pkg.cgi?$pkgnum">View this package (#$pkgnum)</A> | 
89 <A HREF="../view/cust_main.cgi?$custnum">View this customer (#$custnum)</A> | 
90 END
91 } else {
92   print <<END;
93 <A HREF="../misc/cancel-unaudited.cgi?$svcnum">Cancel this (unaudited)account</A> |
94 END
95 }
96
97 print <<END;
98 <A HREF="../">Main menu</A></CENTER><BR>
99 <FONT SIZE=+1>Service #$svcnum</FONT>
100 END
101
102 print qq!<BR><A HREF="../edit/svc_acct.cgi?$svcnum">Edit this information</A>!;
103 #print qq!<BR><A HREF="../misc/sendconfig.cgi?$svcnum">Send account information</A>!;
104 print qq!<BR><BR><A HREF="#general">General</A> | <A HREF="#shell">Shell account</A> | !;
105 print qq!<A HREF="#slip">SLIP/PPP account</A></CENTER>!;
106
107 #formatting
108 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="general">General</A></FONT></CENTER>!;
109
110 #svc
111 print "Service: <B>", $part_svc->svc, "</B>";
112
113 #username
114 print "<BR>Username: <B>", $svc_acct->username, "</B>";
115
116 #password
117 if (substr($svc_acct->_password,0,1) eq "*") {
118   print "<BR>Password: <I>(Login disabled)</I><BR>";
119 } else {
120   print "<BR>Password: <I>(hidden)</I><BR>";
121 }
122
123 # popnum -> svc_acct_pop record
124 my($svc_acct_pop)=qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
125
126 #pop
127 print "POP: <B>", $svc_acct_pop->city, ", ", $svc_acct_pop->state,
128       " (", $svc_acct_pop->ac, ")/", $svc_acct_pop->exch, "<\B>"
129   if $svc_acct_pop;
130
131 #shell account
132 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="shell">!;
133 if ($svc_acct->uid ne '') {
134   print "Shell account";
135   print "</A></FONT></CENTER>";
136   print "Uid: <B>", $svc_acct->uid, "</B>";
137   print "<BR>Gid: <B>", $svc_acct->gid, "</B>";
138
139   print qq!<BR>Finger name: <B>!, $svc_acct->finger, qq!</B><BR>!;
140
141   print "Home directory: <B>", $svc_acct->dir, "</B><BR>";
142
143   print "Shell: <B>", $svc_acct->shell, "</B><BR>";
144
145   print "Quota: <B>", $svc_acct->quota, "</B> <I>(unimplemented)</I>";
146 } else {
147   print "No shell account.</A></FONT></CENTER>";
148 }
149
150 # SLIP/PPP
151 print qq!<HR><CENTER><FONT SIZE=+1><A NAME="slip">!;
152 if ($svc_acct->slipip) {
153   print "SLIP/PPP account</A></FONT></CENTER>";
154   print "IP address: <B>", ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) ? "<I>(Dynamic)</I>" : $svc_acct->slipip ,"</B>";
155   my($attribute);
156   foreach $attribute ( grep /^radius_/, fields('svc_acct') ) {
157     #warn $attribute;
158     $attribute =~ /^radius_(.*)$/;
159     my($pattribute) = ($1);
160     $pattribute =~ s/_/-/g;
161     print "<BR>Radius $pattribute: <B>". $svc_acct->getfield($attribute), "</B>";
162   }
163 } else {
164   print "No SLIP/PPP account</A></FONT></CENTER>"
165 }
166
167 print "<HR>";
168
169         #formatting
170         print <<END;
171
172   </BODY>
173 </HTML>
174 END
175