1 | #!perl -w
|
---|
2 |
|
---|
3 | ###########################################################################
|
---|
4 | #
|
---|
5 | # webpage_editcol.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 for saving an edited config file
|
---|
29 |
|
---|
30 | package webpage_editcol;
|
---|
31 |
|
---|
32 | use CGI;
|
---|
33 | use GSDLHOME;
|
---|
34 | use gflock;
|
---|
35 |
|
---|
36 | require util;
|
---|
37 | require webpageutil;
|
---|
38 |
|
---|
39 | sub parse_cgiargs
|
---|
40 | {
|
---|
41 | # get arguments
|
---|
42 | my $cgi = new CGI;
|
---|
43 | my %args = ();
|
---|
44 |
|
---|
45 | foreach $p ($cgi->param())
|
---|
46 | {
|
---|
47 | $args{$p} = $cgi->param($p);
|
---|
48 | }
|
---|
49 |
|
---|
50 | return \%args;
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 | sub main
|
---|
56 | {
|
---|
57 | # get arguments
|
---|
58 | my $args = parse_cgiargs();
|
---|
59 |
|
---|
60 | my $dirname = $args->{'bc1dirname'};
|
---|
61 | if (!defined($dirname))
|
---|
62 | {
|
---|
63 | # directory name derived from the collection name missing
|
---|
64 | my $mess = "Directory name for collection missing.";
|
---|
65 | &webpageutil::error_location($args,$mess);
|
---|
66 | return;
|
---|
67 | }
|
---|
68 |
|
---|
69 | my $cfg_filename
|
---|
70 | = &util::filename_cat($ENV{'GSDLHOME'},"collect",$dirname,"etc","collect.cfg");
|
---|
71 |
|
---|
72 | if (open(CFGOUT,">$cfg_filename"))
|
---|
73 | {
|
---|
74 | binmode (CFGOUT); # windows
|
---|
75 |
|
---|
76 | if (&gflock::lock (webpage_editcol::CFGOUT)) {
|
---|
77 | my $cfg_text = $args->{'bc1cfgfile'};
|
---|
78 | print CFGOUT "$cfg_text";
|
---|
79 | &gflock::unlock (webpage_editcol::CFGOUT);
|
---|
80 | close(CFGOUT);
|
---|
81 | }
|
---|
82 | else
|
---|
83 | {
|
---|
84 | # problem locking file
|
---|
85 | my $mess = "Unable to lock configuration file: $cfg_filename";
|
---|
86 | &webpageutil::error_location($args,$mess);
|
---|
87 | return;
|
---|
88 | }
|
---|
89 | }
|
---|
90 | else
|
---|
91 | {
|
---|
92 | # unable to open configuration file for writing
|
---|
93 | my $mess = "Unable to open for writing configuration file: $cfg_filename";
|
---|
94 | &webpageutil::error_location($args,$mess);
|
---|
95 | return;
|
---|
96 | }
|
---|
97 |
|
---|
98 | my $mess_url = "$args->{'httpbuild'}&bca=mess&bc1dirname=$dirname";
|
---|
99 | print "Location: $mess_url&head=_headdone_&mess=_messdoneeditcol_\n\n";
|
---|
100 | return;
|
---|
101 |
|
---|
102 | }
|
---|
103 |
|
---|
104 | &main();
|
---|
105 |
|
---|
106 |
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|