#!/usr/bin/perl # This Script and the readme may only be given away "as is", unmodified # and complete. The Script is Freeware. # Created and Copyright by Ralf Gueldemeister # on 25.12.98 # Translate (русский перевод) White Russian Bear require config; # HTML Part # ######################## # WILLKOMMEN.HTML - печатается перед тем, как пользователь регистрируется sub willkommen_html { print << "[END]"; $html_title - Login $html_css $meta $html_bodytag

$html_title

Вход в чат

Ник:
Пароль:

Зарегистрировать новый ник

[END] } #CHATINPUT.HTML здесь рисуются поля ввода sub chatinput_html { print <<"[END]"; $html_css $meta $html_bodytag
[END] &select_user; print <<"[END]";  настройка профиль
 пауза покинуть чат
 Courier-Home
[END] } #STILLALIVE.HTML - the users online frame sub stillalive_html_header { print <<"[END]"; $html_css $meta $html_bodytag [END] } sub stillalive_html_footer { print <<"[END]"; [END] } #CHAT.HTML sub chat_html_header { print "\n\n"; if (!$query{'pause'}) { if ($ENV{'HTTP_USER_AGENT'} =~ /MSIE/) { print <<"[END]"; [END] } else { print "\n"; } } print "\n"; print "\n"; print $html_css; print "\n"; print $html_bodytag2; if ($query{'new_msg_on_top'} == 1) { print "\n\n" if ($query{'new_msg_on_top'} == 1); print "$chat_msg[26]

\n" if ($query{'pause'}); } } sub chat_html_footer { if ($query{'new_msg_on_top'} == 0) { print "\n"; print "

$chat_msg[26]\n" if ($query{'pause'}); } print <<"[END]"; [END] } # MESSAGES Part # ######################## $chat_msg[0] = "wrong masterpassword"; # wrong masterpassword $chat_msg[1] = "unknown command"; # unknown command $chat_msg[2] = "no number of days specified"; # no number of days specified $chat_msg[3] = << "[END]"; # msg printed on /help (DON'T REMOVE "[END]") /msg Псевдоним Сообщение - Послать приватное сообщение лицу с указанным Псевдонимом
/help - Выдать этот текст помощи
/about - Выдать информацию о программе
/me - Акция (Например: "/me сказал: Всем привет!" выдаст "* user сказал: Всем привет!")
/userinfo Псевдоним - Информация о персоне (Не обязательно присутствующей)
/memo Псевдоним Сообщение - Оставить сообщение для отсутствующей персоны

Административные команды:
/list_nicks Пароль - Полный список пользователей (в том числе отсутствующих)
/clean_old_nicks Пароль x - Удалить всех пользователей, кто не заходил в чат x дней
/remove_nick Пароль Псевдоним - Удалить указанный Псевдоним
/ban Пароль Псевдоним - Запретить пользователю доступ в чат
/ban Пароль ip:x.x.x.x - Забанить ip (Работает только когда пользователь с забаненным ip входит, и вы также выбрасываете/баните пользователя вручную)
/kick Пароль Псевдоним - Выпнуть пользователя из чата
/unban Пароль Псевдоним - Разбанить пользователя по псевдониму
/unban Пароль ip:x.x.x.x - снять бан с IP-адреса
/banned_list Пароль - список заБАНенных пользователей и IP-адресов
/admin_memo Пароль Сообщение - отослать сообщение ВСЕМ пользователят от Админа
/ip Пароль Псевдоним - отобразить IP-адрес пользователя
[END] $chat_msg[4] = "покинул чат"; # [user] has left the chat $chat_msg[5] = "пользователей"; # users $chat_msg[6] = "пользователь"; # user $chat_msg[7] = "онлайн"; # online $chat_msg[8] = "Ник";# Nickname $chat_msg[9] = "создан"; # Created on $chat_msg[10] = "последний визит"; # last visited $chat_msg[11] = "текущий\последний IP"; # current/last ip $chat_msg[12] = "статус"; # status $chat_msg[13] = "кол-во записок"; # #memos $chat_msg[14] = "нормальные"; # normal $chat_msg[15] = "кикнутые"; # kicked $chat_msg[16] = "заБАНенные"; # banned $chat_msg[17] = "удалённый пользователи"; # removed users $chat_msg[18] = "всего"; # total $chat_msg[19] = "удалено"; # removed $chat_msg[20] = "не существует"; # doesnot exist $chat_msg[21] = "всем пользователям"; # to all users $chat_msg[22] = "разбаненные"; # unbanned $chat_msg[23] = "записка для"; # Memo for $chat_msg[24] = "успешно отослана"; # was posted successfully $chat_msg[25] = "все пользователи"; # all users $chat_msg[26] = "продолжить"; # continue # Main Part - DON'T CHANGE ANYTHING HERE! # ####################### &action; # Fuehrt je nach action variable gegebene sub aus # action im FORM definieren! exit; sub action { if ($qs eq "") { # Wenn query_string leer sprung zum &welcome; # welcome-teil, 1st visit seite } elsif ($query{'action'} eq "chatinput_html") { &header; &chatinput_html; } elsif ($query{'action'} eq "stillalive") { &stillalive; } elsif ($query{'action'} eq "chat") { &chat; } elsif ($query{'action'} eq "postmsg") { &postmsg; } elsif ($query{'action'} eq "chatnoframes_html") { &header; &chatnoframes_html; } else { &error; } } sub welcome { # Aufruf beim ersten Programmstart &header; &willkommen_html; } sub stillalive { # stillalive/who prozedur &checkpass; if (-e "$data_dir/$data_stillalive_file") { # SAfile oeffnen/erstellen } else { &create_file("$data_dir/$data_stillalive_file"); } open (SAFILE, "<$data_dir/$data_stillalive_file") || &error("opening safile failed"); flock(SAFILE,2) if ($flocking == 1); my $safile = ; # Daten aus safile an $safile uebergeben close SAFILE; local @sa = split (/;;/, $safile); &repair_safile if ($#sa % 2 == 0); # wenn safile fehlerhaft -> repair my $ownsaexists = 0; my $i = 0; for ($i = 0; $i <= $#sa; $i += 2) { # eigenen Eintrag erneuern if ($sa[$i] eq $query{'name'}) { $sa[$i+1] = time; $ownsaexists=1; } } # Eintraege nach ueberfaelligen (aelter als 70s) durchsuchen und diese entfernen for ($i = 1; $i <= $#sa; $i+=2) { if ($sa[$i] < (time - 70)) { # ist zeitstempel schon aelter als 70s? #print logout msg open (CHATFILE, ">>$data_dir/$data_msg_file"); flock(CHATFILE,2) if ($flocking == 1); print CHATFILE "".$sa[$i-1]." ".$chat_msg[4]."\n"; close CHATFILE; $sa[$i] = "//2delete"; $sa[$i-1] = "//2delete"; # zu loeschende eintraege mit //2delete ersetzten } } # alle Felder mit //2delete entfernen my $templsa = $#sa; # Laenge von @sa wird in templsa gespeichert; for ($i=0; $i<=$templsa; $i++) { $temp = shift(@sa); if ($temp ne "//2delete") { push(@sa,$temp); } } # if no own sa entry exists -> add if ($ownsaexists != 1) { $sa[++$#sa] = $query{'name'}; $sa[++$#sa] = time; } $safile = join(';;', @sa); open (SAFILE, ">$data_dir/$data_stillalive_file") || &error("opening safile failed"); flock(SAFILE,2) if ($flocking == 1); print SAFILE $safile; close SAFILE; my $nrusers = ($#sa+1) / 2; my $users = $nrusers > 1 ? $chat_msg[5] : $chat_msg[6]; if ($query{'noframes'} == 1) { print "$nrusers $users $chat_msg[7]: \n"; for ($i=0; $i<=$#sa; $i+=2) { print "$sa[$i] "; } } else { &header; &stillalive_html_header; print "$nrusers $users $chat_msg[7]

\n"; for ($i=0; $i<=$#sa; $i+=2) { print "$sa[$i]
"; } &stillalive_html_footer; } } sub chat { # Chatprocedure: show Messages if (-e "$data_dir/$data_msg_file") { # CHATFILE oeffnen/erstellen } else { &create_file("$data_dir/$data_msg_file"); } &checkpass; if ($query{'noframes'} != 1) { &header; &chat_html_header; } open (CHATFILE, "<$data_dir/$data_msg_file") || &error("opening chatfile failed"); flock(CHATFILE,2) if ($flocking == 1); my @chatfile = ; close CHATFILE; # Ausgabe Messages foreach(@chatfile) { while ($_ =~ /(.*)/; if ($2 + $query{'updatefrequency'} > $timestamp) { $_ = "$1$3\n"; } } $_ =~ s/\n?//g; if ($_) { $query{'new_msg_on_top'} == 1 ? unshift @chatmsgs, $_ : print "$_
\n"; } } if ($query{'new_msg_on_top'} == 1) { for (@chatmsgs) { print "$_
\n"; } } &chat_html_footer if ($query{'noframes'} != 1); } sub postmsg { open (CHATFILE, "<$data_dir/$data_msg_file") || &error("opening chatfile failed"); flock(CHATFILE,2) if ($flocking == 1); my @chatfile = ; close CHATFILE; # alte Eintraege >$message_limit loeschen for (my $i=0; $i <= ($#chatfile - $message_limit); $i++) { shift(@chatfile); } open (CHATFILE, ">$data_dir/$data_msg_file") || &error("opening chatfile failed"); flock(CHATFILE,2) if ($flocking == 1); print CHATFILE @chatfile; close CHATFILE; # check name+password &checkpass; $query{'msg'} = &wash_msg($query{'msg'}); if (substr($query{'msg'},0,1) eq "/" ) { # msg = command? &command("$query{'msg'}"); } elsif ($query{'msg_to'} ne "") { &command("/msg $query{'msg_to'} $query{'msg'}"); } elsif ($query{'msg'} ne "") { # poste msg nach $data_dir/message open (CHATFILE, ">>$data_dir/$data_msg_file"); flock(CHATFILE,2) if ($flocking == 1); # set userspecified font color if not standard if ($query{'color'} eq "standard") { print CHATFILE "$query{'name'}: $query{'msg'}\n"; } else { print CHATFILE "$query{'name'}: $query{'msg'}\n"; } close CHATFILE; # LOG ACTION if ($logtype >= 3) { open (LOGFILE, ">>$log_dir/$log_file") || &error("::open $log_dir/$log_file failed::"); flock(LOGFILE,2) if ($flocking == 1); print LOGFILE localtime(time)." $ENV{'REMOTE_ADDR'} [MSG] $query{'name'}: $query{'msg'}\n"; close LOGFILE; } } &header; if ($query{'noframes'} == 1) { &chatnoframes_html; } else { &chatinput_html; } } sub command { # Kommandoprozedur fuer /cmd ; parameter 0: commandstring $_[0] = $_[0]." "; $_[0] = substr($_[0], 1, length($_[0])-1); my @cmdargs = split(/ /, $_[0]); my $thecommand = substr($_[0],0 , index($_[0], " ")); if ($thecommand eq "msg") { my $msg_to = $cmdargs[1]; $_[0]=substr($_[0], index($_[0], " ")+1, length($_[0])); $_[0]=substr($_[0], index($_[0], " ")+1, length($_[0])); if ($_[0] ne "" && $_[0] ne " ") { &postprivatemsg($query{'name'}, "->".$msg_to, $_[0]); &postprivatemsg($msg_to, $query{'name'}, $_[0]); } } elsif ($thecommand =~ /^help$/i) { &help; } elsif ($thecommand =~ /^about$/i) { &about; } elsif ($thecommand =~ /^me$/i) { $_[0]=substr($_[0], index($_[0], " ")+1, length($_[0])); &me_action($query{'name'}, $_[0]); } elsif ($thecommand =~ /^list_nicks$/i) { my $usermpass = $cmdargs[1]; if ($usermpass eq $masterpassword) { &list_nicks; } else { &postprivatemsg($query{'name'}, "LIST_NICKS", $chat_msg[0]); } } elsif ($thecommand =~ /^clean_old_nicks$/i) { my $usermpass = $cmdargs[1]; my $cleandate = $cmdargs[2]; if ($usermpass eq $masterpassword) { if ($cleandate ne "") { &clean_old_nicks($cleandate); } else { &postprivatemsg($query{'name'}, "CLEAN_OLD_NICKS", $chat_msg[2]); } } else { &postprivatemsg($query{'name'}, "CLEAN_OLD_NICKS", $chat_msg[0]); } } elsif ($thecommand =~ /^remove_nick$/i) { my $usermpass = $cmdargs[1]; my $nick2rm = $cmdargs[2]; if ($usermpass eq $masterpassword) { &remove_nick($nick2rm); } else { &postprivatemsg($query{'name'}, "REMOVE_NICK", $chat_msg[0]); } } elsif ($thecommand =~ /^userinfo$/i) { $query{'infoabout'} = $cmdargs[1]; $userinfo_as_private_msg = 1; &userinfo; } elsif ($thecommand =~ /^ban$/i) { if ($cmdargs[1] eq $masterpassword) { &kick_or_ban_nick($cmdargs[2], 2); } else { &postprivatemsg($query{'name'}, "BAN", $chat_msg[0]); } } elsif ($thecommand =~ /^kick$/i) { if ($cmdargs[1] eq $masterpassword) { &kick_or_ban_nick($cmdargs[2], 1); } else { &postprivatemsg($query{'name'}, "KICK", $chat_msg[0]); } } elsif ($thecommand =~ /^banned_list$/i) { if ($cmdargs[1] eq $masterpassword) { &banned_list; } else { &postprivatemsg($query{'name'}, "BANNED_LIST", $chat_msg[0]); } } elsif ($thecommand =~ /^unban$/i) { if ($cmdargs[1] eq $masterpassword) { &unban($cmdargs[2], 2); } else { &postprivatemsg($query{'name'}, "UNBAN", $chat_msg[0]); } } elsif ($thecommand =~ /^memo$/i) { $_[0]=substr($_[0], index($_[0], " ")+1, length($_[0])); $_[0]=substr($_[0], index($_[0], " ")+1, length($_[0])); &memo($cmdargs[1],$query{'name'}, $_[0]); } elsif ($thecommand =~ /^ip$/i) { if ($cmdargs[1] eq $masterpassword) { &ip($cmdargs[2]); } else { &postprivatemsg($query{'name'}, "IP", $chat_msg[0]); } } elsif ($thecommand =~ /^admin_memo$/i) { if ($cmdargs[1] eq $masterpassword) { $_[0]=substr($_[0], index($_[0], " ")+1, length($_[0])); $_[0]=substr($_[0], index($_[0], " ")+1, length($_[0])); &admin_memo($query{'name'}, $_[0]); } else { &postprivatemsg($query{'name'}, "ADMIN_MEMO", $chat_msg[0]); } } else { &postprivatemsg($query{'name'}, "HELP", "$chat_msg[1]: $_[0]"); } } sub help { &postprivatemsg($query{'name'}, "HELP", $chat_msg[3]); } sub me_action { # parameter 0: wer 1: was open (CHATFILE, ">>$data_dir/$data_msg_file"); flock(CHATFILE,2) if ($flocking == 1); # set userspecified font color if not standard if ($query{'color'} eq "standard") { print CHATFILE "* $_[0] $_[1]\n"; } else { print CHATFILE "* $_[0] $_[1]\n"; } close CHATFILE; } sub about { &postprivatemsg($query{'name'}, "ABOUT", $about_msg); } sub list_nicks { open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open Nickfile failed::"); my @nickfile = ; # Daten aus nickfile an @nickfile uebergeben close NICKFILE; # nickfile schliessen my $nicklist = ""; for (@nickfile) { $_ =~ s/\n//g; my @nickfileentry = split(/;;/, $_); my $status = ($nickfileentry[10] == 0) ? $chat_msg[14] : $chat_msg[15]; $status = ($nickfileentry[10] == 2) ? $chat_msg[16] : $status; $nicklist = $nicklist.""; } $nicklist = $nicklist."
$chat_msg[8]$config_msg[12]$chat_msg[9]$chat_msg[10]$chat_msg[11]$chat_msg[12]$chat_msg[13]
".$nickfileentry[0]."".$nickfileentry[2]."".$nickfileentry[3]."".localtime($nickfileentry[4])."".$nickfileentry[11]."".$status."".$nickfileentry[12]."
"; &postprivatemsg($query{'name'}, "LIST_NICKS", $nicklist); } sub clean_old_nicks { # clear all old nicks older than $_[0] open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open $data_dir/$data_nicks_file failed::"); my @nickfile = ; close NICKFILE; my @nickfile_matrix = (); for ($i = 0; $i <= $#nickfile; $i++) { chomp($nickfile[$i]); push(@nickfile_matrix, [split(/;;/, $nickfile[$i])]); } my $removed_users = 0; my $removed_users_names = ""; my $nr_of_days = $_[0]; for ($i = 0; $i <= $#nickfile_matrix; $i++) { if ($nickfile_matrix[$i][4] < (time - $nr_of_days*60*60*24) && $nickfile_matrix[$i][0] ne $query{'name'}) { # ist zeitstempel schon aelter als $_[0] tage $removed_users_names = $removed_users_names." $nickfile_matrix[$i][0]"; system 'rm', "$data_dir/$data_private_file.$nickfile_matrix[$i][0]"; # deletes private file $removed_users++; $nickfile_matrix[$i] = "//2delete"; } } # alle Felder mit //2delete entfernen my $templmatrix = $#nickfile_matrix; for (my $i = 0; $i <= $templmatrix; $i++) { my $temp = shift(@nickfile_matrix); if ($temp ne "//2delete") { push(@nickfile_matrix, $temp); } } open (NICKFILE, ">$data_dir/$data_nicks_file"); flock(NICKFILE,2) if ($flocking == 1); for (my $i = 0; $i <= $#nickfile_matrix; $i++) { my $temp = join(';;', @{$nickfile_matrix[$i]}); print NICKFILE $temp."\n"; } close NICKFILE; my @remove_from_uifile = split (/ /, $removed_users_names); for (@remove_from_uifile) { &rm_uientry($_); # delete user from uifile &rm_memoentry($_); # delete memos for user from memofile } &postprivatemsg("$query{'name'}","CLEAN_OLD_NICKS","$chat_msg[17]: $removed_users_names
$chat_msg[18]: $removed_users"); # LOG ACTION if ($logtype >= 1) { open (LOGFILE, ">>$log_dir/$log_file") || &error("::open $log_dir/$log_file failed::"); flock(LOGFILE,2) if ($flocking == 1); print LOGFILE localtime(time)." $ENV{'REMOTE_ADDR'} [CLEAN_OLD_NICKS] $chat_msg[17]: $removed_users_names\n"; close LOGFILE; } } sub remove_nick { # $_[0] = nick to remove open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open $data_dir/$data_nicks_file failed::"); my @nickfile = ; close NICKFILE; my @nickfile_matrix = (); for (my $i = 0; $i <= $#nickfile; $i++) { chomp($nickfile[$i]); push(@nickfile_matrix, [split(/;;/, $nickfile[$i])]); } my $userfound; for (my $i=0; $i<=$#nickfile_matrix; $i++) { if ($nickfile_matrix[$i][0] =~ /^$_[0]$/i) { $nickfile_matrix[$i] = "//2delete"; $userfound=1; } } # alle Felder mit //2delete entfernen my $templmatrix = $#nickfile_matrix; for (my $i = 0; $i <= $templmatrix; $i++) { my $temp = shift(@nickfile_matrix); if ($temp ne "//2delete") { push(@nickfile_matrix, $temp); } } open (NICKFILE, ">$data_dir/$data_nicks_file"); flock(NICKFILE,2) if ($flocking == 1); for (my $i = 0; $i <= $#nickfile_matrix; $i++) { my $temp = join(';;', @{$nickfile_matrix[$i]}); print NICKFILE $temp."\n"; } if ($userfound == 1) { system 'rm', "$data_dir/$data_private_file.$_[0]"; # deletes private file &rm_uientry($_[0]); &rm_memoentry($_[0]); &postprivatemsg("$query{'name'}","REMOVE_NICK","$chat_msg[6] $_[0] $chat_msg[19]"); # LOG ACTION if ($logtype >= 1) { open (LOGFILE, ">>$log_dir/$log_file") || &error("::open $log_dir/$log_file failed::"); flock(LOGFILE,2) if ($flocking == 1); print LOGFILE localtime(time)." $ENV{'REMOTE_ADDR'} [REMOVE_NICK] $_[0] $chat_msg[19]\n"; close LOGFILE; } } else { &postprivatemsg("$query{'name'}","REMOVE_NICK","$chat_msg[6] $_[0] $chat_msg[20]"); } } sub select_user { if (-e "$data_dir/$data_stillalive_file") { # SAfile oeffnen/erstellen } else { &create_file("$data_dir/$data_stillalive_file"); } open (SAFILE, "<$data_dir/$data_stillalive_file") || &error("opening safile failed"); flock(SAFILE,2) if ($flocking == 1); my $safile = ; # Daten aus safile an $safile uebergeben close SAFILE; my @sa = split (/;;/, $safile); print ""; } # remove user from userinfo database sub rm_uientry { # $_[0] = nick to remove from userinfo database if(!-e $data_userinfo_file) { return; } open (UIFILE, "<$data_dir/$data_userinfo_file") || &error("::open $data_dir/$data_userinfo_file failed::"); my @uifile = ; close UIFILE; my @uifile_matrix = (); for (my $i = 0; $i <= $#uifile; $i++) { chomp($uifile[$i]); push(@uifile_matrix, [split(/;;/, $uifile[$i])]); } for (my $i=0; $i<=$#uifile_matrix; $i++) { if ($uifile_matrix[$i][0] =~ /^$_[0]$/i) { # ist nick = nick to remove $uifile_matrix[$i] = "//2delete"; } } # alle Felder mit //2delete entfernen my $templmatrix = $#uifile_matrix; for (my $i = 0; $i <= $templmatrix; $i++) { my $temp = shift(@uifile_matrix); if ($temp ne "//2delete") { push(@uifile_matrix, $temp); } } open (UIFILE, ">$data_dir/$data_userinfo_file"); flock(UIFILE,2) if ($flocking == 1); for (my $i = 0; $i <= $#uifile_matrix; $i++) { my $temp = join(';;', @{$uifile_matrix[$i]}); print UIFILE $temp."\n"; } close UIFILE; } # remove memos for user from memo database sub rm_memoentry { # $_[0] = nick to remove if(!-e $data_memo_file) { return; } open (MEMOFILE, "<$data_dir/$data_memo_file") || &error("::open $data_dir/$data_memo_file failed::"); my @memofile = ; close UIFILE; my @memofile_matrix = (); for (my $i = 0; $i <= $#memofile; $i++) { chomp($memofile[$i]); push(@memofile_matrix, [split(/;;/, $memofile[$i])]); } for (my $i=0; $i<=$#memofile_matrix; $i++) { if ($memofile_matrix[$i][0] =~ /^$_[0]$/i) { # ist nick = nick to remove $memofile_matrix[$i] = "//2delete"; } } # alle Felder mit //2delete entfernen my $templmatrix = $#memofile_matrix; for (my $i=0; $i<=$templmatrix; $i++) { my $temp = shift(@memofile_matrix); if ($temp ne "//2delete") { push(@memofile_matrix,$temp); } } open (MEMOFILE, ">$data_dir/$data_memo_file"); flock(MEMOFILE,2) if ($flocking == 1); for (my $i = 0; $i <= $#memofile_matrix; $i++) { my $temp = join(';;', @{$memofile_matrix[$i]}); print MEMOFILE $temp."\n"; } close MEMOFILE; } sub kick_or_ban_nick { # $_[0] nick to kick/ban, $_[1] banlevel (1=kick, 2=ban) if ($_[0] =~ /^ip:/i) { open (BANFILE, ">>$data_dir/$data_banned_file"); flock(BANFILE,2) if ($flocking == 1); print BANFILE "$_[0];;"; close BANFILE; &postprivatemsg("$query{'name'}","BAN","IP ".substr($_[0],3)." $chat_msg[16]"); return; } open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open $data_dir/$data_nicks_file failed::"); my @nickfile = ; # Daten aus nickfile an @nickfile uebergeben close NICKFILE; # nickfile schliessen my @nickfile_matrix = (); for (my $i = 0; $i <= $#nickfile; $i++) { chomp($nickfile[$i]); push(@nickfile_matrix, [split(/;;/, $nickfile[$i])]); } for (my $bani=0; $bani<=$#nickfile_matrix; $bani++) { if ($nickfile_matrix[$bani][0] =~ /^$_[0]$/i) { $nickfile_matrix[$bani][10] = $_[1]; open (NICKFILE, ">$data_dir/$data_nicks_file"); flock(NICKFILE,2) if ($flocking == 1); for (my $i2=0; $i2<=$#nickfile_matrix; $i2++) { my $temp = join(';;', @{$nickfile_matrix[$i2]}); print NICKFILE $temp."\n"; } close NICKFILE; # post ban msg if ($_[1] == 1) { &postprivatemsg("$query{'name'}","KICK","User $_[0] $chat_msg[15]"); } elsif ($_[1] == 2) { &postprivatemsg("$query{'name'}","BAN","User $_[0] $chat_msg[16]"); open (BANFILE, ">>$data_dir/$data_banned_file"); flock(BANFILE,2) if ($flocking == 1); print BANFILE "$_[0];;"; close BANFILE; } } } } sub banned_list { open (BANFILE, "<$data_dir/$data_banned_file"); my $banfile = ; $banfile =~ s/;;/
/g; close BANFILE; &postprivatemsg("$query{'name'}","BANNED_LIST","$chat_msg[16]:
$banfile"); } sub unban { open (BANFILE, "<$data_dir/$data_banned_file"); my $banfile = ; my @temp = split(/;;/, $banfile); for (my $i=0; $i<=@temp; $i++) { if ($temp[$i] eq $_[0]) { # ist nick/ip = nick/ip to unban $temp[$i] = "//2delete"; &postprivatemsg("$query{'name'}","UNBAN","$chat_msg[6] $_[0] $chat_msg[22]"); } } # alle Felder mit //2delete entfernen my $templ = $#temp; for (my $i=0; $i<=$templ; $i++) { my $temp2 = shift(@temp); if ($temp2 ne "//2delete") { push(@temp,$temp2); } } open (BANFILE, ">$data_dir/$data_banned_file"); flock(BANFILE,2) if ($flocking == 1); print BANFILE join(';;', @temp); close BANFILE; open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open $data_dir/$data_nicks_file failed::"); my @nickfile = ; # Daten aus nickfile an @nickfile uebergeben close NICKFILE; # nickfile schliessen my @nickfile_matrix = (); for (my $i = 0; $i <= $#nickfile; $i++) { chomp($nickfile[$i]); push(@nickfile_matrix, [split(/;;/, $nickfile[$i])]); } for (my $bani=0; $bani<=$#nickfile_matrix; $bani++) { if ($nickfile_matrix[$bani][0] =~ /^$_[0]$/i) { $nickfile_matrix[$bani][10] = 0; open (NICKFILE, ">$data_dir/$data_nicks_file"); flock(NICKFILE,2) if ($flocking == 1); for (my $i = 0; $i <= $#nickfile_matrix; $i++) { my $temp = join(';;', @{$nickfile_matrix[$i]}); print NICKFILE $temp."\n"; } close NICKFILE; } } } sub memo { # check if recipient is valid open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open $data_dir/$data_nicks_file failed::"); my @nickfile = ; close NICKFILE; my @nickfile_matrix = (); for (my $i = 0; $i <= $#nickfile; $i++) { chomp($nickfile[$i]); push(@nickfile_matrix, [split(/;;/, $nickfile[$i])]); } for (my $i=0; $i<=$#nickfile_matrix; $i++) { if ($nickfile_matrix[$i][0] =~ /^$_[0]$/i) { $userfound=1; $nickfile_matrix[$i][12]++; # increase number of memos } } open (NICKFILE, ">$data_dir/$data_nicks_file"); flock(NICKFILE,2) if ($flocking == 1); for (my $mi = 0; $mi <= $#nickfile_matrix; $mi++) { my $temp = join(';;', @{$nickfile_matrix[$mi]}); print NICKFILE $temp."\n"; } close NICKFILE; my $memo_msg_to = $_[0]; my $memo_msg_from = $_[1]; my $memo_msg = $_[2]; my $memo_time = time; if ($userfound != 1) { &postprivatemsg("$query{'name'}","MEMO","$chat_msg[6] $_[0] $chat_msg[20]"); return; } open (MEMOFILE, ">>$data_dir/$data_memo_file") || &error("opening memofile failed"); flock(MEMOFILE,2) if ($flocking == 1); print MEMOFILE "$memo_msg_to;;$memo_msg_from;;$memo_msg;;$memo_time\n"; close MEMOFILE; &postprivatemsg("$query{'name'}","MEMO","$chat_msg[23] $_[0] $chat_msg[24]"); } sub wash_msg { # $_[0] string to 'wash' # kill ; $_[0] =~ s/;/;/g; # kill html-tags $_[0] =~ s//>/g; # kill linebreaks $_[0] =~ s/\n/
/g; # link urls # http://* $_[0] =~ s/(\bhttp:\/\/.[^\ ]+)/$1<\/A>/g; # ftp://* $_[0] =~ s/(\bftp:\/\/.*\b)/$1<\/A>/g; # mailto:* $_[0] =~ s/(\bmailto:.*\b)/$1<\/A>/g; return $_[0]; } sub admin_memo { open (NICKFILE, "<$data_dir/$data_nicks_file"); my @nickfile = ; close NICKFILE; my @userlist; for (@nickfile) { chomp($_); my @nickfileentry = split(/;;/, $_); $nickfileentry[12]++; push(@nickfile_matrix, [@nickfileentry]); push (@userlist, $nickfileentry[0]); } open (NICKFILE, ">$data_dir/$data_nicks_file"); flock(NICKFILE,2) if ($flocking == 1); for (my $ami = 0; $ami <= $#nickfile_matrix; $ami++) { my $temp = join(';;', @{$nickfile_matrix[$ami]}); print NICKFILE $temp."\n"; } my $memo_msg_to = $chat_msg[25]; my $memo_msg_from = $_[0]; my $memo_msg = $_[1]; my $memo_time = time; open (MEMOFILE, ">>$data_dir/$data_memo_file") || &error("opening memofile failed"); flock(MEMOFILE,2) if ($flocking == 1); for (@userlist) { print MEMOFILE "$_;;$memo_msg_from;;$memo_msg;;$memo_time\n"; } close MEMOFILE; &postprivatemsg("$query{'name'}","ADMIN_MEMO","$chat_msg[23] $memo_msg_to $chat_msg[24]"); } sub ip { open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open Nickfile failed::"); my @nickfile = ; # Daten aus nickfile an @nickfile uebergeben close NICKFILE; # nickfile schliessen my $ip; for (@nickfile) { $_ =~ s/\n//g; my @nickfileentry = split(/;;/, $_); if ($nickfileentry[0] =~ /^$_[0]$/i) { $ip = $nickfileentry[11]; } } if ($ip) { &postprivatemsg("$query{'name'}","IP","$_[0]: $ip"); } else { &postprivatemsg("$query{'name'}","IP","$config_msg[1]"); } } # END Main Part # ##############################