From 9e10edb996b206d531caa5f929a117cefb790355 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 10 Jul 2002 16:22:49 +0000 Subject: Changed thesaurus filenames from nn-foo to nn.foo Moved save_thesaurus() from Conf.pm to Thesaurus.pm --- Echolot/Thesaurus.pm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'Echolot/Thesaurus.pm') diff --git a/Echolot/Thesaurus.pm b/Echolot/Thesaurus.pm index ba68a69..be97446 100644 --- a/Echolot/Thesaurus.pm +++ b/Echolot/Thesaurus.pm @@ -1,7 +1,7 @@ package Echolot::Thesaurus; # (c) 2002 Peter Palfrader -# $Id: Thesaurus.pm,v 1.5 2002/07/07 01:12:00 weasel Exp $ +# $Id: Thesaurus.pm,v 1.6 2002/07/10 16:22:49 weasel Exp $ # =pod @@ -23,6 +23,26 @@ use English; use HTML::Template; +sub save_thesaurus($$$) { + my ($otype, $oid, $data) = @_; + + return 1 unless Echolot::Config::get()->{'thesaurus'}; + + my ($type) = $otype =~ /^([a-z-]+)$/; + cluck("type '$otype' is not clean in save_thesaurus"), return 0 unless defined $type; + my ($id) = $oid =~ /^([0-9]+)$/; + cluck("id '$oid' is not clean in save_thesaurus"), return 0 unless defined $id; + + my $file = Echolot::Config::get()->{'thesaurusdir'}.'/'.$id.'.'.$type; + open (F, ">$file") or + cluck ("Cannot open '$file': $!"), + return 0; + print F $data; + close (F); + + return 1; +}; + sub build_thesaurus() { return 1 unless Echolot::Config::get()->{'thesaurus'}; @@ -38,7 +58,7 @@ sub build_thesaurus() { my $data; for my $filename (@files) { - my ($id, $what) = $filename =~ /^(\d+)-(adminkey|conf|help|key|stats)$/; + my ($id, $what) = $filename =~ /^(\d+)\.(adminkey|conf|help|key|stats)$/; next unless (defined $id && defined $what); my $remailer = Echolot::Globals::get()->{'storage'}->get_address_by_id($id); -- cgit v1.2.3