source: main/tags/2.11/gsdl/cgi-bin/webpage_editcol.pl@ 21107

Last change on this file since 21107 was 724, checked in by davidb, 25 years ago

Perl CGI scripts to help in webpage based collection building.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1#!/usr/local/bin/perl5 -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
30use CGI;
31use GSDLHOME;
32use Fcntl ':flock';
33
34require util;
35require webpageutil;
36
37sub parse_cgiargs
38{
39 # get arguments
40 my $cgi = new CGI;
41 my %args = ();
42
43 foreach $p ($cgi->param())
44 {
45 $args{$p} = $cgi->param($p);
46 }
47
48 return \%args;
49}
50
51
52
53sub main
54{
55 # get arguments
56 my $args = parse_cgiargs();
57
58 my $dirname = $args->{'bc1dirname'};
59 if (!defined($dirname))
60 {
61 # directory name derived from the collection name missing
62 my $mess = "Directory name for collection missing.";
63 &webpageutil::error_location($args,$mess);
64 return;
65 }
66
67 my $cfg_filename
68 = &util::filename_cat($ENV{'GSDLHOME'},"collect",$dirname,"etc","collect.cfg");
69
70 if (open(CFGOUT,">$cfg_filename"))
71 {
72 if (flock(CFGOUT,LOCK_EX))
73 {
74 my $cfg_text = $args->{'bc1cfgfile'};
75 print CFGOUT "$cfg_text";
76 flock(CFGOUT,LOCK_UN);
77 close(CFGOUT);
78 }
79 else
80 {
81 # problem locking file
82 my $mess = "Unable to lock configuration file: $cfg_filename";
83 &webpageutil::error_location($args,$mess);
84 return;
85 }
86 }
87 else
88 {
89 # unable to open configuration file for writing
90 my $mess = "Unable to open for writing configuration file: $cfg_filename";
91 &webpageutil::error_location($args,$mess);
92 return;
93 }
94
95 my $mess_url = "$args->{'httpbuild'}&bca=mess&bc1dirname=$dirname";
96 print "Location: $mess_url&head=_headdone_&mess=_messdoneeditcol_\n\n";
97 return;
98
99}
100
101&main();
102
103
104
105
106
Note: See TracBrowser for help on using the repository browser.