From: ndparker <> Date: Sun, 17 Jun 2001 00:15:40 +0000 (+0000) Subject: added version check and comments X-Git-Url: https://git.p6c8.net/selfforum.git/commitdiff_plain/ce34f7e9e1943ea798985e84560beab23d36fd31 added version check and comments --- diff --git a/selfforum-cgi/shared/Conf/Admin.pm b/selfforum-cgi/shared/Conf/Admin.pm index 09bb103..5d07736 100644 --- a/selfforum-cgi/shared/Conf/Admin.pm +++ b/selfforum-cgi/shared/Conf/Admin.pm @@ -1,48 +1,104 @@ -# Admin.pm +package Conf::Admin; -# ==================================================== -# Autor: n.d.p. / 2001-01-05 -# lm : n.d.p. / 2001-02-25 -# ==================================================== -# Funktion: -# Einlesen der Admindefaultkonfiguration -# ==================================================== +################################################################################ +# # +# File: shared/CheckRFC.pm # +# # +# Authors: Andre Malo , 2001-06-16 # +# # +# Description: read and parse admin default config # +# # +################################################################################ use strict; - -package Conf::Admin; - -use vars qw(@EXPORT); +use vars qw( + @EXPORT + $VERSION +); use Lock qw(:READ); use XML::DOM; -# ==================================================== -# Funktionsexport -# ==================================================== +################################################################################ +# +# Version check +# +$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +################################################################################ +# +# Export +# use base qw(Exporter); @EXPORT = qw(read_admin_conf); -################################ -# sub read_admin_conf +### get_severance () ########################################################### +# +# read out severance config (used twice) # -# Default-Admin-Konf. lesen -################################ +# Params: $severance - element node +# +# Return: hashref +# +sub get_severance ($) { + my $severance = shift; + + my $after_byte = $severance -> getElementsByTagName ('AfterByte', 0) -> item (0); + my $after_message = $severance -> getElementsByTagName ('AfterMessage', 0) -> item (0); + my $after_thread = $severance -> getElementsByTagName ('AfterThread', 0) -> item (0); + my $last_posting = $severance -> getElementsByTagName ('AfterLastPosting', 0) -> item (0); + my %conf =( + exArchiving => $severance -> getAttribute ('executeArchiving'), + archiving => $severance + -> getElementsByTagName ('Archiving', 0) -> item (0) + -> getElementsByTagName ('*', 0) -> item (0) -> getTagName, + severance => $severance -> getAttribute ('executeSeverance'), + afterByte => ( + $after_byte + ? $after_byte -> getFirstChild -> getData + : undef + ), + afterThread => ( + $after_thread + ? $after_thread -> getFirstChild -> getData + : undef + ), + afterMessage => ( + $after_message + ? $after_message -> getFirstChild -> getData + : undef + ), + lastPosting => ( + $last_posting + ? $last_posting -> getFirstChild -> getData + : undef + ) + ); + + \%conf; +} + +### read_admin_conf () ######################################################### +# +# read and parse admin config +# +# Params: $filename - filename +# +# Return: hashref +# sub read_admin_conf ($) { my $filename=shift; my %conf; - if (-f $filename) { # gibts die Datei ueberhaupt? - if (lock_file ($filename)) { # sperren... - my $xml = new XML::DOM::Parser -> parsefile ($filename); # ...einlesen und parsen... - violent_unlock_file ($filename) unless (unlock_file ($filename)); # ...freigeben - - # ================================= - # jetzt Daten in den Hash schreiben + if (-f $filename) { + if (lock_file ($filename)) { + my $xml = new XML::DOM::Parser -> parsefile ($filename); + violent_unlock_file ($filename) unless (unlock_file ($filename)); + # write data into the hash + # my $forum = $xml -> getElementsByTagName ('Forum',0) -> item (0); # View @@ -56,18 +112,22 @@ sub read_admin_conf ($) { my $quoting = $forum_view -> getElementsByTagName ('Quoting', 0) -> item (0); my $char = $quoting -> getElementsByTagName ('Chars', 0) -> item (0); - $conf {View} = {threadOpen => $thread_view -> getAttribute ('threadOpen'), - countMessages => $thread_view -> getAttribute ('countMessages'), - sortThreads => $thread_view -> getAttribute ('sortThreads'), - sortMessages => $thread_view -> getAttribute ('sortMessages'), - showThread => (($how_name eq 'ShowAll')?undef: - (($how_name eq 'ShowNone')?1: - ($show_how -> getFirstChild -> getData))), - showPreview => $message_view -> getAttribute ('previewON'), - showNA => $flags -> getAttribute ('showNA'), - showHQ => $flags -> getAttribute ('showHQ'), - quoting => $quoting -> getAttribute ('quotingON'), - quoteChars => $char?$char -> getFirstChild -> getData:undef}; + $conf {View} = { + threadOpen => $thread_view -> getAttribute ('threadOpen'), + countMessages => $thread_view -> getAttribute ('countMessages'), + sortThreads => $thread_view -> getAttribute ('sortThreads'), + sortMessages => $thread_view -> getAttribute ('sortMessages'), + showThread => (($how_name eq 'ShowAll') + ? undef + : (($how_name eq 'ShowNone') + ? 1 + : ($show_how -> getFirstChild -> getData))), + showPreview => $message_view -> getAttribute ('previewON'), + showNA => $flags -> getAttribute ('showNA'), + showHQ => $flags -> getAttribute ('showHQ'), + quoting => $quoting -> getAttribute ('quotingON'), + quoteChars => $char?$char -> getFirstChild -> getData:undef + }; my $voting = $forum -> getElementsByTagName ('Voting', 0) -> item (0); $conf {Voting} = { @@ -76,22 +136,36 @@ sub read_admin_conf ($) { }; # Severance - $conf {Severance} = &get_severance ($forum -> getElementsByTagName ('Severance', 0) -> item (0)); + $conf {Severance} = get_severance ($forum -> getElementsByTagName ('Severance', 0) -> item (0)); # Messaging my $messaging = $forum -> getElementsByTagName ('Messaging', 0) -> item (0); my $call_by_user = $messaging -> getElementsByTagName ('CallByUser', 0) -> item (0); - $conf {Messaging} = {userAnswer => $messaging -> getAttribute ('callUserAnswer'), - thread => $messaging -> getAttribute ('callAdminThread'), - na => $messaging -> getAttribute ('callAdminNA'), - hq => $messaging -> getAttribute ('callAdminHQ'), - voting => $messaging -> getAttribute ('callAdminVoting'), - archiving => $messaging -> getAttribute ('callAdminArchiving'), - byUser => $messaging -> getAttribute ('callUserAnswer'), - callByName => [$call_by_user?map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Name', 0):()], - callByMail => [$call_by_user?map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Email', 0):()], - callByIP => [$call_by_user?map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('IpAddress', 0):()]}; + $conf {Messaging} = { + userAnswer => $messaging -> getAttribute ('callUserAnswer'), + thread => $messaging -> getAttribute ('callAdminThread'), + na => $messaging -> getAttribute ('callAdminNA'), + hq => $messaging -> getAttribute ('callAdminHQ'), + voting => $messaging -> getAttribute ('callAdminVoting'), + archiving => $messaging -> getAttribute ('callAdminArchiving'), + byUser => $messaging -> getAttribute ('callUserAnswer'), + callByName => [ + $call_by_user + ? map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Name', 0) + : () + ], + callByMail => [ + $call_by_user + ? map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('Email', 0) + : () + ], + callByIP => [ + $call_by_user + ? map {$_ -> getFirstChild -> getData} $call_by_user -> getElementsByTagName ('IpAddress', 0) + : () + ] + }; # Instant my $instant = $forum -> getElementsByTagName ('InstantJob', 0) -> item (0); @@ -99,57 +173,44 @@ sub read_admin_conf ($) { my $job_name = $job -> getTagName; $job_name = $job -> getAttribute ('reason') if ($job_name ne 'Severance'); - $conf {Instant} = {execute => $instant -> getAttribute ('executeJob'), - description => $job_name, - url => (($job_name ne 'Severance')?$job -> getElementsByTagName ('FileUrl', 0) -> item (0) -> getFirstChild -> getData:undef), - Severance => (($job_name eq 'Severance')?&get_severance ($job):undef)}; + $conf {Instant} = { + execute => $instant -> getAttribute ('executeJob'), + description => $job_name, + url => ( + ($job_name ne 'Severance') + ? $job -> getElementsByTagName ('FileUrl', 0) -> item (0) -> getFirstChild -> getData + : undef + ), + Severance => ( + ($job_name eq 'Severance') + ? get_severance ($job) + : undef + ) + }; # User my $user = $forum -> getElementsByTagName ('UserManagement', 0) -> item (0); - $conf {User} = {deleteAfterDays => $user -> getElementsByTagName ('DeleteUser', 0) -> item (0) - -> getElementsByTagName ('AfterDays', 0) -> item (0) - -> getFirstChild -> getData}; + $conf {User} = { + deleteAfterDays => $user + -> getElementsByTagName ('DeleteUser', 0) -> item (0) + -> getElementsByTagName ('AfterDays', 0) -> item (0) + -> getFirstChild -> getData + }; } else { - violent_unlock_file ($filename);}} - - # Rueckgabe - \%conf; -} - -# ==================================================== -# Private Funktionen -# ==================================================== - -sub get_severance ($) { - my $severance = shift; - - my $after_byte = $severance -> getElementsByTagName ('AfterByte', 0) -> item (0); - my $after_message = $severance -> getElementsByTagName ('AfterMessage', 0) -> item (0); - my $after_thread = $severance -> getElementsByTagName ('AfterThread', 0) -> item (0); - my $last_posting = $severance -> getElementsByTagName ('AfterLastPosting', 0) -> item (0); - - my %conf =( exArchiving => $severance -> getAttribute ('executeArchiving'), - archiving => $severance -> getElementsByTagName ('Archiving', 0) -> item (0) - -> getElementsByTagName ('*', 0) -> item (0) -> getTagName, - severance => $severance -> getAttribute ('executeSeverance'), - afterByte => ($after_byte?$after_byte -> getFirstChild -> getData:undef), - afterThread => ($after_thread?$after_thread -> getFirstChild -> getData:undef), - afterMessage => ($after_message?$after_message -> getFirstChild -> getData:undef), - lastPosting => ($last_posting?$last_posting -> getFirstChild -> getData:undef)); + violent_unlock_file ($filename); + } + } + # return \%conf; } -# ==================================================== -# Modulinitialisierung -# ==================================================== - -# making require happy +# keep 'require' happy 1; -# ==================================================== -# end of Conf::Admin -# ==================================================== \ No newline at end of file +# +# +### end of Conf::Admin #########################################################