############### Dieser TeFil enthält Programmcode, der an verschiedenen
##SHARED-SUBS## Stellen ausgeführt werden muß und jedem Skript zur
############### Verfügung steht.
sub reload_html {
print "
";
$client->shutdown(2);
exit 0;
}
sub printfile { # Liest eine externe Datei ein und gibt sie mit print aus
my ($file2print,$pagetitle,$bodyclass) = @_;
&start_html($pagetitle,$bodyclass)
if ($pagetitle ne "");
&menu
unless ($bodyclass eq "blank");
open(FILE2PRINT,"<$file2print");
print "$_\n"
while();
close FILE2PRINT;
}
sub start_html { # Der HEADER einer HTML-Datei
print "$title - $_[0]$_[2]";
&style;
print "";
if ($_[1] eq "start") {
print "";
} elsif ($_[1] ne "") {
print "";
} else {
print "";
}
}
sub post { # Öffentliche Nachricht posten.
my ($room,$msg2post,$alias,$secroom) = @_;
my @rooms = $room;
@rooms = ($room,$secroom)
if ($room ne $secroom);
foreach my $theroom (@rooms) {
open(MSGFILE,">>data/msgs/$theroom");
print MSGFILE "!<;".time."<;!<;!<;$msg2post
<;$alias<;\n";
close MSGFILE;
opendir(PID,"data/online/pids/$theroom");
my @pids = readdir(PID);
closedir(PID);
foreach(@pids) {
kill USR1 => $_
if (-f "data/online/pids/$theroom/$_");
}
}
&log($msg2post)
if ($room eq $standardroom);
}
sub post_prv { # Private Nachricht posten (flüstern).
my ($alias2post,$msg2post) = @_;
my $roomofalias = &get_room($alias2post);
return false
if (!$roomofalias);
open(MSGFILE,">>data/msgs/$roomofalias");
print MSGFILE "$alias2post<;".time."<;!<;!<;$msg2post
<;$alias<;\n";
close MSGFILE;
opendir(PID,"data/online/pids/$roomofalias");
my @pids = readdir(PID);
closedir(PID);
foreach(@pids) {
kill USR1 => $_
if (-f "data/online/pids/$roomofalias/$_");
}
return true;
}
sub post_strmsg { # Einen Befehl an den Chat-Stream-Prozess senden
my ($alias,$room, $command,$action) = @_;
open MSGFILE,">>data/msgs/$room";
print MSGFILE "$alias<;".time."<;$command<;$action<;!<;!<;\n";
close MSGFILE;
opendir(PID,"data/online/pids/$room");
my @pids = readdir(PID);
closedir(PID);
foreach(@pids) {
kill USR1 => $_
if (-f "data/online/pids/$room/$_");
}
}
sub log { # Protokollieren der Nachrichten etc.
my $msg2log = $_[0];
my ($secs, $mins, $hours, $days, $months, $years) = &timearray;
my $js;
($msg2log,$js) = split(/<;\n";
close MSGFILE;
opendir PID,"data/online/pids/$room";
my @pids = readdir(PID);
closedir(PID);
foreach(@pids) {
kill USR1 => $_
if (-f "data/online/pids/$room/$_");
}
}
sub get_theme { # Raumthema eines Raums holen
my $room = shift;
open RSTAT,"data/online/rstat/$room";
my @rstat = ;
close RSTAT;
chomp($rstat[1]);
return "Raumthema:".$rstat[1]
if ($rstat[1] ne undef);
}
sub get_room { # Den Raum finden, wo sich Alias befindet
my $alias = shift;
opendir(DIR,"data/online/rooms");
my @dir = readdir(DIR);
closedir(DIR);
foreach my $room (@dir) {
opendir(DIR,"data/online/rooms/$room");
my @chatter = readdir(DIR);
closedir(DIR);
foreach my $chatter (@chatter) {
return $room
if ($chatter eq $alias);
}
}
}
sub debug { open DEBUG,">data/debug"; while(@_) { chomp; print DEBUG "$_\n"; } close DEBUG;}
1;