source: branches/New_Config_Format-branch/gsdl/cgi-bin/webpage_delcol.pl@ 1279

Last change on this file since 1279 was 1279, checked in by sjboddie, 24 years ago

merged changes to trunk into New_Config_Format branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1#!perl -w
2
3###########################################################################
4#
5# webpage_delcol.pl --
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 1999 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28# This program is a webpage wrapper that deletes the named collection
29
30use CGI;
31use GSDLHOME;
32
33require util;
34require webpageutil;
35
36sub parse_cgiargs
37{
38 # get arguments
39 my $cgi = new CGI;
40 my %args = ();
41
42 foreach $p ($cgi->param())
43 {
44 $args{$p} = $cgi->param($p);
45 }
46
47 return \%args;
48}
49
50
51
52sub main
53{
54 # get arguments
55 my $args = parse_cgiargs();
56
57 my $dirname = $args->{'bc1dirname'};
58 if (!defined($dirname))
59 {
60 # directory name derived from the collection name missing
61 my $mess = "Directory name derived from the collection name missing.";
62 &webpageutil::error_location($args,$mess);
63 return;
64 }
65
66 my $delete_area = $args->{'bc1deletearea'};
67
68 if ($delete_area eq "all")
69 {
70 # delete all files
71 my $col_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$dirname);
72 &util::rm_r($col_dir);
73
74 }
75 elsif ($delete_area eq "import")
76 {
77
78 my $collectdir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$dirname);
79 my $import_dir = &util::filename_cat($collectdir,"import");
80 my $archives_dir = &util::filename_cat($collectdir,"archives");
81 &util::rm_r($import_dir,$archives_dir);
82 &util::mk_dir($import_dir);
83 }
84 elsif ($delete_area eq "archives")
85 {
86 my $collectdir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$dirname);
87 my $archives_dir = &util::filename_cat($collectdir,"archives");
88 &util::rm_r($archives_dir);
89 }
90 else
91 {
92 # unrecoginised area to delete
93 my $mess = "Unrecognised area to delete: $delete_area";
94 &webpageutil::error_location($args,$mess);
95 return;
96 }
97
98 my $mess_url = "$args->{'httpbuild'}&bca=mess";
99 $mess_url .= "&bc1dirname=$dirname" if ($delete_area ne "all");
100 print "Location: $mess_url&head=_headdone_&mess=_messdonedelcol_\n\n";
101 return;
102
103}
104
105&main();
106
107
Note: See TracBrowser for help on using the repository browser.