all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
[freeside.git] / htdocs / misc / expire_pkg.cgi
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: expire_pkg.cgi,v 1.2 1998-12-17 09:12:44 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.2  1998-12-17 09:12:44  ivan
20 # s/CGI::(Request|Base)/CGI.pm/;
21 #
22
23 use strict;
24 use Date::Parse;
25 use CGI;
26 use CGI::Carp qw(fatalsToBrowser);
27 use FS::UID qw(cgisuidsetup);
28 use FS::CGI qw(popurl eidiot);
29 use FS::Record qw(qsearchs);
30 use FS::cust_pkg;
31
32 my($cgi) = new CGI;
33 &cgisuidsetup($cgi);
34
35 #untaint date & pkgnum
36
37 my($date);
38 if ( $cgi->param('date') ) {
39   str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date";
40   $date=$1;
41 } else {
42   $date='';
43 }
44
45 $cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum";
46 my($pkgnum)=$1;
47
48 my($cust_pkg) = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
49 my(%hash)=$cust_pkg->hash;
50 $hash{expire}=$date;
51 my($new)=create FS::cust_pkg ( \%hash );
52 my($error) = $new->replace($cust_pkg);
53 &eidiot($error) if $error;
54
55 print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum'));
56