for mod_perl: no more top-level my() variables; use vars instead
[freeside.git] / htdocs / misc / expire_pkg.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: expire_pkg.cgi,v 1.3 1999-01-19 05:14:05 ivan Exp $
4 #
5 # Usage: post form to:
6 #        http://server.name/path/expire_pkg.cgi
7 #
8 # Note: Should be run setuid freeside as user nobody
9 #
10 # based on susp_pkg
11 # ivan@voicenet.com 97-jul-29
12 #
13 # ivan@sisd.com 98-mar-17 FS::Search->FS::Record
14 #
15 # Changes to allow page to work at a relative position in server
16 #       bmccane@maxbaud.net     98-apr-3
17
18 # $Log: expire_pkg.cgi,v $
19 # Revision 1.3  1999-01-19 05:14:05  ivan
20 # for mod_perl: no more top-level my() variables; use vars instead
21 # also the last s/create/new/;
22 #
23 # Revision 1.2  1998/12/17 09:12:44  ivan
24 # s/CGI::(Request|Base)/CGI.pm/;
25 #
26
27 use strict;
28 use vars qw ( $cgi $date $pkgnum $cust_pkg %hash $new $error );
29 use Date::Parse;
30 use CGI;
31 use CGI::Carp qw(fatalsToBrowser);
32 use FS::UID qw(cgisuidsetup);
33 use FS::CGI qw(popurl eidiot);
34 use FS::Record qw(qsearchs);
35 use FS::cust_pkg;
36
37 $cgi = new CGI;
38 &cgisuidsetup($cgi);
39
40 #untaint date & pkgnum
41
42 if ( $cgi->param('date') ) {
43   str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date";
44   $date=$1;
45 } else {
46   $date='';
47 }
48
49 $cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum";
50 $pkgnum = $1;
51
52 $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
53 %hash = $cust_pkg->hash;
54 $hash{expire}=$date;
55 $new = new FS::cust_pkg ( \%hash );
56 $error = $new->replace($cust_pkg);
57 &eidiot($error) if $error;
58
59 print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum'));
60