<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Admin.pm

# ====================================================
# Autor: n.d.p. / 2001-01-05
# lm   : n.d.p. / 2001-02-25
# ====================================================
# Funktion:
#      Einlesen der Admindefaultkonfiguration
# ====================================================

use strict;

package Conf::Admin;

use vars qw(@EXPORT);

use Lock qw(:READ);

use XML::DOM;

# ====================================================
# Funktionsexport
# ====================================================

use base qw(Exporter);
@EXPORT = qw(read_admin_conf);

################################
# sub read_admin_conf
#
# Default-Admin-Konf. lesen
################################

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 -&gt; parsefile ($filename);           # ...einlesen und parsen...
      violent_unlock_file ($filename) unless (unlock_file ($filename));  # ...freigeben

      # =================================
      # jetzt Daten in den Hash schreiben

      my $forum = $xml -&gt; getElementsByTagName ('Forum',0) -&gt; item (0);

      # View
      my $forum_view      = $forum       -&gt; getElementsByTagName ('ForumView', 0) -&gt; item (0);
        my $thread_view   = $forum_view  -&gt; getElementsByTagName ('ThreadView', 0) -&gt; item (0);
          my $show_thread = $thread_view -&gt; getElementsByTagName ('ShowThread', 0) -&gt; item (0);
            my $show_how  = $show_thread -&gt; getElementsByTagName ('*', 0) -&gt; item (0);
            my $how_name  = $show_how -&gt; getTagName;
        my $message_view  = $forum_view  -&gt; getElementsByTagName ('MessageView', 0) -&gt; item (0);
        my $flags         = $forum_view  -&gt; getElementsByTagName ('Flags', 0) -&gt; item (0);
        my $quoting       = $forum_view  -&gt; getElementsByTagName ('Quoting', 0) -&gt; item (0);
          my $char        = $quoting     -&gt; getElementsByTagName ('Chars', 0) -&gt; item (0);

      $conf {View} = {threadOpen    =&gt; $thread_view -&gt; getAttribute ('threadOpen'),
                      countMessages =&gt; $thread_view -&gt; getAttribute ('countMessages'),
                      sortThreads   =&gt; $thread_view -&gt; getAttribute ('sortThreads'),
                      sortMessages  =&gt; $thread_view -&gt; getAttribute ('sortMessages'),
                      showThread    =&gt; (($how_name eq 'showAll')?undef:
                                       (($how_name eq 'showNone')?1:
                                       ($show_how -&gt; getFirstChild -&gt; getData))),
                      showPreview   =&gt; $message_view -&gt; getAttribute ('previewON'),
                      showNA        =&gt; $flags -&gt; getAttribute ('showNA'),
                      showHQ        =&gt; $flags -&gt; getAttribute ('showHQ'),
                      quoting       =&gt; $quoting -&gt; getAttribute ('quotingON'),
                      quoteChars    =&gt; $char?$char -&gt; getFirstChild -&gt; getData:undef};

      # Severance
      $conf {Severance} = &amp;get_severance ($forum -&gt; getElementsByTagName ('Severance', 0) -&gt; item (0));

      # Messaging
      my $messaging      = $forum     -&gt; getElementsByTagName ('Messaging', 0) -&gt; item (0);
        my $call_by_user = $messaging -&gt; getElementsByTagName ('CallByUser', 0) -&gt; item (0);

      $conf {Messaging} = {userAnswer =&gt; $messaging -&gt; getAttribute ('callUserAnswer'),
                           thread     =&gt; $messaging -&gt; getAttribute ('callAdminThread'),
                           na         =&gt; $messaging -&gt; getAttribute ('callAdminNA'),
                           hq         =&gt; $messaging -&gt; getAttribute ('callAdminHQ'),
                           voting     =&gt; $messaging -&gt; getAttribute ('callAdminVoting'),
                           archiving  =&gt; $messaging -&gt; getAttribute ('callAdminArchiving'),
                           byUser     =&gt; $messaging -&gt; getAttribute ('callUserAnswer'),
                           callByName =&gt; [map {$_ -&gt; getFirstChild -&gt; getData} $call_by_user -&gt; getElementsByTagName ('Name', 0)],
                           callByMail =&gt; [map {$_ -&gt; getFirstChild -&gt; getData} $call_by_user -&gt; getElementsByTagName ('Email', 0)],
                           callByIP   =&gt; [map {$_ -&gt; getFirstChild -&gt; getData} $call_by_user -&gt; getElementsByTagName ('IpAddress', 0)]};

      # Instant
      my $instant    = $forum   -&gt; getElementsByTagName ('InstantJob', 0) -&gt; item (0);
        my $job      = $instant -&gt; getElementsByTagName ('*',0) -&gt; item (0);
        my $job_name = $job -&gt; getTagName;
        $job_name = $job -&gt; getAttribute ('reason') if ($job_name ne 'Severance');

      $conf {Instant} = {execute     =&gt; $instant -&gt; getAttribute ('executeJob'),
                         description =&gt; $job_name,
                         url         =&gt; (($job_name ne 'Severance')?$job -&gt; getElementsByTagName ('FileUrl', 0) -&gt; item (0) -&gt; getFirstChild -&gt; getData:undef),
                         Severance   =&gt; (($job_name eq 'Severance')?&amp;get_severance ($job):undef)};

      # User
      my $user = $forum -&gt; getElementsByTagName ('UserManagement', 0) -&gt; item (0);

      $conf {User} = {deleteAfterDays =&gt; $user -&gt; getElementsByTagName ('DeleteUser', 0) -&gt; item (0)
                                               -&gt; getElementsByTagName ('AfterDays', 0) -&gt; item (0)
                                               -&gt; getFirstChild -&gt; getData};
    }

    else {
      violent_unlock_file ($filename);}}

  # Rueckgabe
  \%conf;
}

# ====================================================
# Private Funktionen
# ====================================================

sub get_severance ($) {
  my $severance = shift;

  my $after_byte    = $severance -&gt; getElementsByTagName ('AfterByte', 0) -&gt; item (0);
  my $after_message = $severance -&gt; getElementsByTagName ('AfterMessage', 0) -&gt; item (0);
  my $after_thread  = $severance -&gt; getElementsByTagName ('AfterThread', 0) -&gt; item (0);
  my $last_posting  = $severance -&gt; getElementsByTagName ('AfterLastPosting', 0) -&gt; item (0);

  my %conf =( exArchiving  =&gt; $severance -&gt; getAttribute ('executeArchiving'),
              archiving    =&gt; $severance -&gt; getElementsByTagName ('Archiving', 0) -&gt; item (0)
                                -&gt; getElementsByTagName ('*', 0) -&gt; item (0) -&gt; getTagName,
              severance    =&gt; $severance -&gt; getAttribute ('executeSeverance'),
              afterByte    =&gt; ($after_byte?$after_byte -&gt; getFirstChild -&gt; getData:undef),
              afterThread  =&gt; ($after_thread?$after_thread -&gt; getFirstChild -&gt; getData:undef),
              afterMessage =&gt; ($after_message?$after_message -&gt; getFirstChild -&gt; getData:undef),
              lastPosting  =&gt; ($last_posting?$last_posting -&gt; getFirstChild -&gt; getData:undef));

  \%conf;
}

# ====================================================
# Modulinitialisierung
# ====================================================

# making require happy
1;

# ====================================================
# end of Conf::Admin
# ====================================================</pre></body></html>