From 630af0ed6c0af69c7df2e45aef7a87722a3c00c0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:47 +0200 Subject: tagging ychat-perl-legacy --- 0.8.1/modules/shared.pm | 353 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 353 insertions(+) create mode 100755 0.8.1/modules/shared.pm (limited to '0.8.1/modules/shared.pm') diff --git a/0.8.1/modules/shared.pm b/0.8.1/modules/shared.pm new file mode 100755 index 0000000..e458953 --- /dev/null +++ b/0.8.1/modules/shared.pm @@ -0,0 +1,353 @@ +sub reload_html { + print ""; + &del_awake(); + $client->shutdown(2); + exit 0; +} +sub printfile { + my($file2print, $pagetitle, $bodyclass) = @_; + &start_html($pagetitle, $bodyclass) if $pagetitle ne ''; + &menu unless $bodyclass eq 'blank'; + open FILE2PRINT, "<$file2print"; + print "$_\n" while defined($_ = ); + close FILE2PRINT; +} +sub start_html { + print "$title - $_[0]$_[2]"; + &style; + print ''; + if ($_[1] eq 'start') { + print ''; + } + elsif ($_[1] ne '') { + print ""; + } + else { + print ''; + } +} +sub log { + my $msg2log = $_[0]; + my($secs, $mins, $hours, $days, $months, $years) = &timearray; + my $js; + $hours--; + ($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 { + 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 { + 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; + } + } + return undef; +} +sub get_ident { + my ($alias,$line) = @_; + open IDENT, "data/online/ident/$alias"; + my (@ident) = ; + close IDENT; + chomp $ident[$line]; + return $ident[$line]; +} +sub get_online_users { + my @dir = &diropen('data/online/rooms'); + my @users; + + foreach my $room (@dir) { + next if $room =~ /\./; + my @room = &diropen("data/online/rooms/$room"); + + foreach (@room) { + push @users, $_ unless /\./; + } + } + return @users; +} +sub get_online_time { + my $alias = shift; + if (-f "data/user/options/$alias") { + open ONLINE, "; + close ONLINE; + return sprintf('%.2f', $online / 3600); + } + return false; +} +sub diropen { + my $dir = shift; + + opendir DIR, $dir; + my @dir = readdir(DIR); + closedir(DIR); + + return @dir; +} +sub del_awake { + unlink "data/online/awake/$$"; +} +sub debug { + open DEBUG, '>>debug'; + while (@_) { + chomp $_; + print DEBUG "$_\n"; + } + close DEBUG; +} +1; -- cgit v1.2.3