Chatbox

Talk to me!

new users:
you have to register a nick before you login
nicks not in use for 40 days will be deleted
#!/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 require config; # HTML Part # ######################## #REGISTER.HTML - Printed when user registers new nick sub register_html { print <<"[END]"; $html_title - register new nick $html_css $html_bodytag

Register New Nick

new Nickname:
Password:
Password again:
eMail:
(only for administration)

[END] } #BANNER.HTML - the banner on the top - You may change or remove it! sub banner_html { print <<"[END]"; $html_css $html_bodytag
MARIHUANA Chat MARIHUANA
[END] } #OPTIONS.HTML - the options page sub options_html { print <<"[END]"; $html_title - Options $html_css $html_bodytag

Options

Update Frequency (secs):
Font Color:
Message order
Login Sound

Change password

old password:
new password:
new password again:
[END] } #USERINFO.HTML - information about the users, click on user in online list sub userinfo_html { print <<"[END]"; $html_title - User Information $html_css $html_bodytag

User Information

[END] print "
" if ($userinfo{'photo_url'} ne ""); print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
nickname:$query{'infoabout'}
real name:$userinfo{'realname'}
email:$userinfo{'email'}
age:$userinfo{'age'}
city:$userinfo{'city'}
country:$userinfo{'country'}
homepage url:$userinfo{'url'}
ICQ uin:$userinfo{'icq_uin'}
anything else:$userinfo{'stuff'}
"; print "
" if ($userinfo{'photo_url'} ne ""); print <<"[END]";
[END] } #CHANGEUSERINFO.HTML - change user information sub changeuserinfo_html { print <<"[END]"; $html_title - Change User Information $html_css $html_bodytag

Change User Information

real name:
email:
country:
city:
age:
homepage url:
picture url:
ICQ uin:
everything else:
[END] } #SCRIPTLINKS.HTML - Links to other chatscripts sub scriptlinks_html { print <<"[END]"; $html_css $html_bodytag chat 2 [END] } #CHATFRAMES.HTML sub chatframes_html { print "$html_title\n"; if ($banner_picture) { print " \n" } else { print " \n" } print " \n" if ($banner_picture); print " \n"; print " \n"; # print " \n"; #UNCOMMENT IF YOU WANT MULTIPLE SCRIPT SUPPORT print " \n"; # print " \n"; #UNCOMMENT IF YOU WANT MULTIPLE SCRIPT SUPPORT print " \n"; # print " \n"; #UNCOMMENT IF YOU WANT MULTIPLE SCRIPT SUPPORT print " \n"; print "\n"; print "\n"; } # MESSAGES Part # ######################## $chat2_msg[0] = "has entered the chat"; # [user] has entered the chat # illegal_nick_html $chat2_msg[1] = "Illegal Nick"; # Illegal Nick $chat2_msg[2] = "Your Nick \"$query{'name'}\" contains illegal characters
A Nick may contain only letters, numbers and the underdash \"_\".
retry"; # Your Nick \"$query{'name'}\" contains illegal characters
A Nick may contain only letters, numbers and the underdash \"_\".
retry # illegal_pass_html $chat2_msg[3] = "Illegal Password"; # Illegal Password $chat2_msg[4] = "A password may not contain \";\"
retry"; # A password may not contain \";\"
retry # pass_check_failed_html $chat2_msg[5] = "Password Check Failed"; # Password Check Failed $chat2_msg[6] = "The passwords you entered are not equal
retry"; # The passwords you entered are not equal
retry # existingnick_html $chat2_msg[7] = "Nickname already exists"; # Nickname already exists $chat2_msg[8] = "try another nick"; # try another nick # nickcreated_html $chat2_msg[9] = "Your nick is now registered";# Your nick is now registered $chat2_msg[10] = "login"; # login # chat_is_full_html $chat2_msg[11] = "Chat is full"; # Chat is full $chat2_msg[12] = "Sorry, the chat room is full, please try another room or come back another time.
You can login anyway if you login with the password \"yourpassword masterpassword\".
back"; # Sorry, the chat room is full, please try another room or come back another time.
You can login anyway if you login with the password \"yourpassword masterpassword\".
back # send_pwd_html $chat2_msg[13] = "Lost Password"; # Lost Password $chat2_msg[14] = "The password was sent to you.
back"; # The password was sent to you ($query{'email'}).
back # illegal_international_nick_html $chat2_msg[15] = "Illegal Nick"; # Illegal Nick $chat2_msg[16] = "Your Nick \"$query{'name'}\" contains illegal characters
A Nick may not contain \\\";/ :?*<>|
retry"; # Your Nick \"$query{'name'}\" contains illegal characters
A Nick may not contain \\\";/ :?*<>|
retry $chat2_msg[17] = "Password changed"; # Password changed $chat2_msg[18] = "The new password may not contain \";\""; # The new password may not contain \";\" $chat2_msg[19] = "New password check failed, probably mistyped"; # New password check failed, probably mistyped $chat2_msg[20] = "please wait"; # please wait $chat2_msg[21] = "Memo from"; # Memo from $chat2_msg[22] = "[CHAT] Your Password"; # [CHAT] Your Password $chat2_msg[23] = "Your password is"; # Your password is $chat2_msg[24] = "- the admin"; # - the admin $chat2_msg[25] = "Nick"; # Nick # 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 &error("dont't execute this file, run chat.cgi instead"); } elsif ($query{'action'} eq "register") { &header; ®ister_html; } elsif ($query{'action'} eq "login") { &login; } elsif ($query{'action'} eq "create_nick") { &create_nick; } elsif ($query{'action'} eq "banner") { &header; &banner_html; } elsif ($query{'action'} eq "options_html") { &header; &options_html; } elsif ($query{'action'} eq "setoptions") { &setoptions; } elsif ($query{'action'} eq "gotourl") { &gotourl; } elsif ($query{'action'} eq "userinfo") { &userinfo; } elsif ($query{'action'} eq "changeuserinfo") { &changeuserinfo; } elsif ($query{'action'} eq "setuserinfo") { &setuserinfo; } elsif ($query{'action'} eq "show_users") { &show_users; } elsif ($query{'action'} eq "scriptlinks") { &header; &scriptlinks_html; } elsif ($query{'action'} eq "send_pwd") { &send_pwd; } elsif ($query{'action'} eq "show_usernames") { &show_usernames; } else { &error; } } sub login { # Loginprozedur # check login name+password if (-e "$data_dir/$data_nicks_file") { # wenn nickfile existiert dann oeffnen open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open $data_dir/$data_nicks_file failed::"); } else { # sonst nonick_html &header; &user_error_html($config_msg[1], $config_msg[2]); exit; } # check if ip is banned open (BANFILE, "<$data_dir/$data_banned_file"); my $banfile = ; my @banfiletemp = split(/;;/, $banfile); for (@banfiletemp) { if ("ip:".$ENV{'REMOTE_ADDR'} eq $_) { &header; &user_error_html($config_msg[7], $config_msg[8]); exit; } } &max_user_limit; # check if chat is full 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] =~ /^$query{'name'}$/i) { # compare nicks with uppercases $query{'name'} = $nickfile_matrix[$i][0] if ($nickfile_matrix[$i][0] ne $query{'name'}); # if nicks are different, because of some upper cases use the version in the nickfile if ($nickfile_matrix[$i][1] eq $query{'password'}) { # update last visited var $nickfile_matrix[$i][4] = time; # set ip $nickfile_matrix[$i][11] = $ENV{'REMOTE_ADDR'}; #set unkicked if user was kicked $nickfile_matrix[$i][10] = 0 if ($nickfile_matrix[$i][10] == 1); #check if user is banned if ($nickfile_matrix[$i][10] == 2) { close NICKFILE; &header; &user_error_html($config_msg[7], $config_msg[8]); exit; } if ($clear_old_msgs == 1) { &clear_old_msgs_sub; } if ($nickfile_matrix[$i][5] ne "") { $query{'updatefrequency'} = $nickfile_matrix[$i][5]; $query{'color'} = $nickfile_matrix[$i][6]; $query{'new_msg_on_top'} = $nickfile_matrix[$i][9]; $query{'ls'} = $nickfile_matrix[$i][13]; } else { $query{'updatefrequency'} = $updatefrequency; $query{'color'} = "standard"; $query{'new_msg_on_top'} = $new_msg_on_top; } # check memos if ($nickfile_matrix[$i][12] > 0) { $pause = 1; &check_for_memo($nickfile_matrix[$i][12]); } $nickfile_matrix[$i][12] = 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; #post welcome msg if ($welcome_msg ne "") { &postprivatemsg($query{'name'}, "WeedMaster", $welcome_msg); #print login msg open (CHATFILE, ">>$data_dir/$data_msg_file"); flock(CHATFILE,2) if ($flocking == 1); print CHATFILE "".$query{'name'}." ".$chat2_msg[0].""; if ($query{'ls'}) { print CHATFILE "\n"; } else { print CHATFILE "\n"; } close CHATFILE; } &enterchat; # wenn beides richtig goto chat exit; # danach prozedur verlassen } else { &header; &user_error_html($config_msg[3], $config_msg[4]."$query{'name'}".$config_msg[19]); exit; } } } # falls nick falsch nonick_html &header; &user_error_html($config_msg[1], $config_msg[2]); } sub enterchat { # LOG ACTION if ($logtype >= 2) { 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'} [LOGIN] $query{'name'}\n"; close LOGFILE; } if ($query{'noframes'} == 1) { print "Location: $script_name?action=chatnoframes_html&name=$query{'name'}&password=$query{'password'}&color=$query{'color'}&new_msg_on_top=$query{'new_msg_on_top'}&ls=$query{'ls'}&noframes=1\n\n"; } else { &header; &chatframes_html; } } sub validate_string { # params: 0: string to validate # alle strings die spaces, semikolons oder steuerzeichen enthalten if (($_[0] =~ /[\W]/ || $_[0] eq "") && $international_nicks == 0) { return 1; # illegal string } elsif ($_[0] =~ /[\";\/:\\\?\*<>\| ]/ || $_[0] eq "") { return 1; } else { return 0; # legal string } } sub create_nick { # neuen nick anlegen + weiterleiten zum chat if (&validate_string($query{'name'}) == 1) { # ueberpruefen ob nick illegale Zeichen enthaelt &header; if ($international_nicks == 0) { &user_error_html($chat2_msg[1], $chat2_msg[2]); } else { &user_error_html($chat2_msg[15], $chat2_msg[16]); } exit; }; if ($query{'password'} =~ /;/ || !$query{'password'}) { # ueberpruefen ob password illegale Zeichen enthaelt &header; &user_error_html($chat2_msg[3], $chat2_msg[4]); exit; }; if ($query{'password'} ne $query{'password2'}) { &header; &user_error_html($chat2_msg[5], $chat2_msg[6]); exit; }; if (-e "$data_dir/$data_nicks_file") { open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open $data_dir/$data_nicks_file failed::"); } else { &create_file("$data_dir/$data_nicks_file"); open (NICKFILE, "<$data_dir/$data_nicks_file") || &error("::open Nickfile failed::"); # und dann oeffnen } my @nickfile = ; close NICKFILE; my @nickfile_matrix = (); for (my $i = 0; $i <= $#nickfile; $i++) { chomp($nickfile[$i]); push(@nickfile_matrix, [split(/;;/, $nickfile[$i])]); } # does nick already exist? for (my $i=0; $i<=$#nickfile_matrix; $i++) { if ($nickfile_matrix[$i][0] =~ /^$query{'name'}$/i) { &header; # wenn ja dann ausgabe existingnick.htm &user_error_html($chat2_msg[7], $chat2_msg[8]); exit; } } open (NICKFILE, ">>$data_dir/$data_nicks_file") || &error("open nickfile failed"); flock(NICKFILE,2) if ($flocking == 1); my @nickdate; $nickdata[0] = $query{'name'}; $nickdata[1] = $query{'password'}; $nickdata[2] = $query{'email'}; $zeit = time(); $nickdata[3] = localtime($zeit); $nickdata[4] = time; $nickdata[5] = $updatefrequency; $nickdata[6] = "standard"; $nickdata[9] = $new_msg_on_top; my $nickentry = join(';;', @nickdata); print NICKFILE "$nickentry\n"; close NICKFILE; if (-e "$data_dir/$data_private_file.$query{'name'}") { } else { &create_file("$data_dir/$data_private_file.$query{'name'}"); } #MAIL TO ADMIN if ($mail_on_new_registration == 1) { open(MAIL,"|$mailprogramme -t"); print MAIL "To: $admin_email_addresse\n"; print MAIL "From: $admin_email_addresse (Ralfs Chat Script)\n"; print MAIL "Subject: [CHAT] New Nick Registration\n\n"; print MAIL "A new user was registered\n"; print MAIL "Nickname: $query{'name'}\n"; print MAIL "eMail: $query{'email'}\n"; print MAIL "HTTP User Agent: ".$ENV{'HTTP_USER_AGENT'}."\n"; print MAIL "Remote Addresse: ".$ENV{'REMOTE_ADDR'}."\n"; } # 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'} [NEW USER] $query{'name'} <$query{'email'}>\n"; close LOGFILE; } &header; &user_error_html($chat2_msg[9], $chat2_msg[10]); } sub clear_old_msgs_sub { # safile einlesen if (-e "$data_dir/$data_stillalive_file") { open (SAFILE, "<$data_dir/$data_stillalive_file") || &error("opening safile failed"); my $safile = ; close SAFILE; my @sa = split (/;;/, $safile); # Eintraege nach ueberfaelligen (> 50) durchsuchen und diese entfernen my $coms_i = 0; for ($coms_i=1; $coms_i<=$#sa; $coms_i+=2) { if ($sa[$coms_i] < (time - 50)) { # ist zeitstempel schon aelter als 50s? $sa[$coms_i] = "//2delete"; $sa[$coms_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 ($coms_i=0; $coms_i<=$templsa; $coms_i++) { my $temp = shift(@sa); if ($temp ne "//2delete") { push(@sa,$temp); } } # wenn laenge von safile < 0 (chat empty) dann chatfile leeren if ($#sa < 0) { if (-e "$data_dir/$data_msg_file") { # CHATFILE oeffnen open (CHATFILE, ">$data_dir/$data_msg_file") || &error("opening chatfile failed"); print CHATFILE ""; close CHATFILE; } } } } sub setoptions { &checkpass; if ($query{'updatefrequency'}<$min_update_freq || $query{'updatefrequency'} eq "") { $query{'updatefrequency'}=$min_update_freq; } my $cpw_msg; my $change_password_ok = 0; if ($query{'change_pwd_old'} && $query{'change_pwd_new'}) { if ($query{'change_pwd_old'} eq $query{'password'}) { if ($query{'change_pwd_new'} eq $query{'change_pwd_new2'}) { if ($query{'change_pwd_new'} !~ /[;\n]/ || !$query{'change_pwd_new'}) { $change_password_ok = 1; $cpw_msg = $chat2_msg[17]; } else { $cpw_msg = $chat2_msg[18]; } } else { $cpw_msg = $chat2_msg[19]; } } else { $cpw_msg = $config_msg[3]; } &postprivatemsg("$query{'name'}","CHANGE_PWD",$cpw_msg) if ($cpw_msg); $query{'password'} = $query{'change_pwd_new'} if ($change_password_ok == 1); } 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 $i=0; $i<=$#nickfile_matrix; $i++) { if ($nickfile_matrix[$i][0] =~ /^$query{'name'}$/i) { $nickfile_matrix[$i][1] = $query{'password'}; $nickfile_matrix[$i][5] = $query{'updatefrequency'}; $nickfile_matrix[$i][6] = $query{'color'}; $nickfile_matrix[$i][9] = $query{'new_msg_on_top'}; if ($query{'ls'}) { $query{'ls'} =~ s/^(file:)?(\/\/)?(localhost)?\/?(.*)/file:\/\/localhost\/\4/; $nickfile_matrix[$i][13] = $query{'ls'}; } else { $nickfile_matrix[$i][13] = ""; } 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; } } &header; &chatframes_html; } sub setuserinfo { &checkpass; 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])]); } my $info_exists; for (my $i=0; $i<=$#uifile_matrix; $i++) { if ($uifile_matrix[$i][0] =~ /^$query{'name'}$/i) { $info_exists=1; } } if ($info_exists != 1) { $uifile_matrix[$#uifile_matrix+1][0] = $query{'name'}; } for (my $i=0; $i<=$#uifile_matrix; $i++) { if ($uifile_matrix[$i][0] =~ /^$query{'name'}$/i) { $uifile_matrix[$i][1] = $query{'realname'}; $uifile_matrix[$i][2] = $query{'email'}; $uifile_matrix[$i][3] = $query{'age'}; $uifile_matrix[$i][4] = $query{'city'}; $uifile_matrix[$i][5] = $query{'country'}; $uifile_matrix[$i][6] = $query{'url'}; $uifile_matrix[$i][7] = $query{'stuff'}; $uifile_matrix[$i][8] = $query{'photo_url'}; $uifile_matrix[$i][9] = $query{'icq_uin'}; for (my $i2=0; $i2<=9; $i2++) { $uifile_matrix[$i][$i2] =~ s/;/;#59;/g; $uifile_matrix[$i][$i2] =~ s/&/&/g; $uifile_matrix[$i][$i2] =~ s/;#59;/;/g; $uifile_matrix[$i][$i2] =~ s//g; $uifile_matrix[$i][$i2] =~ s/\r//g; } open (UIFILE, ">$data_dir/$data_userinfo_file"); flock(UIFILE,2) if ($flocking == 1); for (my $i = 0; $i <= $#uifile_matrix; $i++) { $temp = join(';;', @{$uifile_matrix[$i]}); print UIFILE $temp."\n"; } close UIFILE; } } &header; &chatframes_html; } sub changeuserinfo { &checkpass; open (UIFILE, "<$data_dir/$data_userinfo_file") || &create_file("$data_dir/$data_userinfo_file"); my @uifile = ; close UIFILE; local @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] =~ /^$query{'name'}$/i) { for (my $i2=0; $i2<=9; $i2++) { $uifile_matrix[$i][$i2] =~ s/;/;/g; $uifile_matrix[$i][$i2] =~ s/&/&/g; $uifile_matrix[$i][$i2] =~ s/
/\n/g; } $userinfo{'realname'} = $uifile_matrix[$i][1]; $userinfo{'email'} = $uifile_matrix[$i][2]; $userinfo{'age'} = $uifile_matrix[$i][3]; $userinfo{'city'} = $uifile_matrix[$i][4]; $userinfo{'country'} = $uifile_matrix[$i][5]; $userinfo{'url'} = $uifile_matrix[$i][6]; $userinfo{'stuff'} = $uifile_matrix[$i][7]; $userinfo{'photo_url'} = $uifile_matrix[$i][8]; $userinfo{'icq_uin'} = $uifile_matrix[$i][9]; } } &header; &changeuserinfo_html; } sub show_users { &header; print &number_of_users; } sub number_of_users { open (SAFILE, "<$data_dir/$data_stillalive_file"); 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 # Eintraege nach ueberfaelligen (aelter als 50s) durchsuchen und diese entfernen for (my $i=1; $i<=$#sa; $i+=2) { if ($sa[$i] < (time - 50)) { # ist zeitstempel schon aelter als 50s? $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 (my $i=0; $i<=$templsa; $i++) { my $temp = shift(@sa); if ($temp ne "//2delete") { push(@sa,$temp); } } $safile = join(';;', @sa); open (SAFILE, ">$data_dir/$data_stillalive_file"); flock(SAFILE,2) if ($flocking == 1); print SAFILE $safile; close SAFILE; my $nrusers = ($#sa+1) / 2; return $nrusers; } sub gotourl { &header; print ""; print ""; print "$chat2_msg[20]"; print ""; } sub max_user_limit { if (&number_of_users >= $max_users && $max_users >= 0) { if ($query{'password'} =~ / $masterpassword$/) { $query{'password'} = substr($query{'password'}, 0, index($query{'password'}, " ")); } else { &header; &user_error_html($chat2_msg[11], $chat2_msg[12]); exit; } } } sub check_for_memo { &create_file("$data_dir/$data_memo_file") if (!-e "$data_dir/$data_memo_file"); open (MEMOFILE, "<$data_dir/$data_memo_file") || &error("opening memofile failed"); flock(MEMOFILE,2) if ($flocking == 1); my @memofile = ; close MEMOFILE; my @memofile_matrix = (); for (my $i = 0; $i <= $#memofile; $i++) { chomp($memofile[$i]); push(@memofile_matrix, [split(/;;/, $memofile[$i])]); } # Eintraege nach ueberfaelligen (aelter als $days_to_keep_memos) durchsuchen und diese entfernen for (my $i=0; $i<=$#memofile_matrix; $i++) { if ($memofile_matrix[$i][3] < (time - $days_to_keep_memos*60*60*24)) { # ist zeitstempel schon aelter als 50s? $memofile_matrix[$i] = "//2delete"; } } for (my $cfm_i=0; $cfm_i<=$#memofile_matrix; $cfm_i++) { if ($memofile_matrix[$cfm_i][0] =~ /^$query{'name'}$/i) { &postprivatemsg($query{'name'},"MEMO","$chat2_msg[21] $memofile_matrix[$cfm_i][1] (".localtime($memofile_matrix[$cfm_i][3])."): $memofile_matrix[$cfm_i][2]"); $memofile_matrix[$cfm_i] = "//2delete"; } } # alle Felder mit //2delete entfernen my $templ = $#memofile_matrix; # Laenge von @sa wird in templsa gespeichert; for (my $i=0; $i<=$templ; $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 send_pwd { 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 $i=0; $i<=$#nickfile_matrix; $i++) { if ($nickfile_matrix[$i][0] =~ /^$query{'name'}$/i) { $query{'email'} = $nickfile_matrix[$i][2]; $query{'password'} = $nickfile_matrix[$i][1] } } # mail to user open(MAIL,"|$mailprogramme -t"); print MAIL "To: $query{'email'}\n"; print MAIL "From: $admin_email_addresse ($html_title)\n"; print MAIL "Subject: $chat2_msg[22]\n\n"; print MAIL "$chat2_msg[23] $query{'password'} ($chat2_msg[25]: $query{'name'})\n\n"; print MAIL "$chat2_msg[24]"; close MAIL; &header; &user_error_html($chat2_msg[13], $chat2_msg[14]); } sub show_usernames { &header; open (SAFILE, "<$data_dir/$data_stillalive_file"); 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 # Eintraege nach ueberfaelligen (aelter als 50s) durchsuchen und diese entfernen for (my $i=1; $i<=$#sa; $i+=2) { if ($sa[$i] < (time - 50)) { # ist zeitstempel schon aelter als 50s? $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 (my $i=0; $i<=$templsa; $i++) { my $temp = shift(@sa); if ($temp ne "//2delete") { push(@sa,$temp); } } $safile = join(';;', @sa); open (SAFILE, ">$data_dir/$data_stillalive_file"); flock(SAFILE,2) if ($flocking == 1); print SAFILE $safile; close SAFILE; for (my $i=0; $i<=$#sa; $i+=2) { print $sa[$i]."
\n"; } }  users are currently online

enter chat now!