############################################################################### # InstantMessage.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Project started by Zef Hemel (zef@zefnet.com) # # Software Version: YaBB 1 Gold - Release # # =========================================================================== # # Software Distributed by: http://yabb.xnull.com # # Support, News, Updates at: http://yabb.xnull.com/community/ # # =========================================================================== # # Copyright (c) 2000-2001 X-Null - All Rights Reserved # # Software by: The YaBB Development Team # ############################################################################### $instantmessageplver="1 Gold - Release"; sub IMIndex { if( $username eq 'Guest' ) { &fatal_error($txt{147}); } $imbox = $txt{'316'}; $txt{'412'} =~ s~IMBOX~$imbox~g; $img{'im_delete'} =~ s~IMBOX~$imbox~g; # Read Membergroups fopen(FILE, "$vardir/membergroups.txt"); @membergroups = ; fclose(FILE); # Load censor list. &LoadCensorList; # Fix moderator showing in info $sender = "im"; $yytitle = $txt{'143'}; &header; print <<"EOT";
   $mbname
   $txt{'144'}
   $txt{'316'}
EOT if( @immessages ) { print qq~ $img{'im_delete'}$menusep~; } print <<"EOT"; $img{'im_outbox'}$menusep$img{'im_new'}$menusep$img{'im_reload'}$menusep$img{'im_config'}
EOT unless( @immessages ) { print <<"EOT"; EOT } @bgcolors = ( $color{windowbg}, $color{windowbg2} ); @bgstyles = qw~windowbg windowbg2~; $bgcolornum = scalar @bgcolors; $bgstylenum = scalar @bgstyles; for( $counter = 0; $counter < @immessages; $counter++ ) { $windowbg = $bgcolors[($counter % $bgcolornum)]; $windowcss = $bgstyles[($counter % $bgstylenum)]; chomp $immessages[$counter]; ($musername, $msub, $mdate, $immessage, $messageid, $mips) = split( /\|/, $immessages[$counter] ); if( $messageid < 100 ) { $messageid = $counter; } if( $msub eq '' ) { $msub = $txt{'24'}; } foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } $mydate = &timeformat($mdate); print<<"EOT"; EOT } if( @immessages ) { print qq~
 $txt{'317'} $txt{'318'} $txt{'319'}  
$txt{'151'}
$mydate $musername $msub $img{'im_remove'}
\n\n~; } if( @immessages ) { print <<"EOT";
EOT } for( $counter = 0; $counter < @immessages; $counter++ ) { $windowbg = $bgcolors[($counter % $bgcolornum)]; $windowcss = $bgstyles[($counter % $bgstylenum)]; ($musername, $msub, $mdate, $immessage, $messageid) = split( /\|/, $immessages[$counter] ); if( $messageid < 100 ) { $messageid = $counter; } if( $msub eq '' ) { $msub = $txt{'24'}; } $mydate = &timeformat($mdate); if( $musername ne 'Guest' && ! $yyUDLoaded{$musername} && -e("$memberdir/$musername.dat") ) { # If user is not in memory, s/he must be loaded. &LoadUserDisplay($musername); } if( $yyUDLoaded{$musername} ) { @userprofile = @{$userprofile{$musername}}; $star = $memberstar{$musername}; $memberinfo = $memberinfo{$musername}; $icqad = $icqad{$musername}; $yimon = $yimon{$musername}; $usernamelink = qq~$userprofile[1]~; $profbutton = $profilebutton && $musername ne 'Guest' ? qq~$menusep$img{'viewprofile'}~ : ''; $postinfo = qq~$txt{'26'}: $userprofile[6]
~; $memail = $userprofile[2]; } #$message .= $userprofile[5]; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $immessage =~ s~\Q$tmpa\E~$tmpb~gi; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } $message = $immessage; # put the message back in the proper variable for doing ubbc if($enable_ubbc) { &DoUBBC; } $message =~ s~(\S{80})(?=\S)~$1\n~g; print <<"EOT"; EOT } print <<"EOT";
 $txt{'29'} $txt{'118'}
$usernamelink
$memberinfo
$star

$postinfo $userprofile[11]
$userprofile[13]$userprofile[12] $userprofile[8] $icqad   $userprofile[10] $yimon   $userprofile[9]
 $msub $txt{'30'}: $mydate

$message
$userprofile[5]
EOT if ($userprofile[19] ne "checked" || $settings[7] eq "Administrator" || $allow_hide_email ne 1) { print << "EOT"; $userprofile[4]$img{'email'}$profbutton EOT } else { print << "EOT"; $userprofile[4]$profbutton EOT } print << "EOT"; $img{'replyquote'}$menusep$img{'reply'}$menusep$img{'im_remove'}
EOT &footer; exit; } sub IMOutbox { if ($username eq 'Guest') { &fatal_error($txt{'147'}); } $imbox = $txt{'320'}; $txt{'412'} =~ s~IMBOX~$imbox~g; $img{'im_delete'} =~ s~IMBOX~$imbox~g; # Read all messages fopen(FILE, "$memberdir/$username.outbox"); @ommessages = ; fclose(FILE); # Fix moderator showing in info $sender = "im"; # Read Membergroups fopen(FILE, "$vardir/membergroups.txt"); @membergroups = ; fclose(FILE); # Load censor list. &LoadCensorList; $yytitle = $txt{'143'}; &header; print <<"EOT";
   $mbname
   $txt{'144'}
   $txt{'320'}
EOT if( @ommessages ) { print qq~ $img{'im_delete'}$menusep~; } print <<"EOT"; $img{'im_inbox'}$menusep$img{'im_new'}$menusep$img{'im_reload'}$menusep$img{'im_config'}
EOT # Display Message if there are no Messages in Users Outbox unless( @ommessages ) { print <<"EOT"; EOT } @bgcolors = ( $color{windowbg}, $color{windowbg2} ); @bgstyles = qw~windowbg windowbg2~; $bgcolornum = scalar @bgcolors; $bgstylenum = scalar @bgstyles; for( $counter = 0; $counter < @ommessages; $counter++ ) { $windowbg = $bgcolors[($counter % $bgcolornum)]; $windowcss = $bgstyles[($counter % $bgstylenum)]; chomp $ommessages[$counter]; ($musername, $msub, $mdate, $immessage, $messageid, $mips) = split( /\|/, $ommessages[$counter] ); if( $messageid < 100 ) { $messageid = $counter; } if( $msub eq '' ) { $msub = $txt{'24'}; } foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } $mydate = &timeformat($mdate); print<<"EOT"; EOT } if(@ommessages) { print qq~
 $txt{'317'} $txt{'324'} $txt{'319'}  
$txt{'151'}
$mydate $musername $msub $img{'im_remove'}
\n\n~; } # Output all messages if( @ommessages ) { print <<"EOT";
EOT } for( $counter = 0; $counter < @ommessages; $counter++ ) { $windowbg = $bgcolors[($counter % $bgcolornum)]; $windowcss = $bgstyles[($counter % $bgstylenum)]; ($musername, $msub, $mdate, $immessage, $messageid) = split( /\|/, $ommessages[$counter] ); if( $messageid < 100 ) { $messageid = $counter; } if( $msub eq '' ) { $msub = $txt{'24'}; } $mydate = &timeformat($mdate); if( $musername ne 'Guest' && ! $yyUDLoaded{$musername} && -e("$memberdir/$musername.dat") ) { # If user is not in memory, s/he must be loaded. &LoadUserDisplay($musername); } if( $yyUDLoaded{$musername} ) { @userprofile = @{$userprofile{$musername}}; $star = $memberstar{$musername}; $memberinfo = $memberinfo{$musername}; $icqad = $icqad{$musername}; $yimon = $yimon{$musername}; $usernamelink = qq~$userprofile[1]~; $profbutton = $profilebutton && $musername ne 'Guest' ? qq~$menusep$img{'viewprofile'}~ : ''; $postinfo = qq~$txt{'26'}: $userprofile[6]
~; $memail = $userprofile[2]; } $message = $immessage; # put the message back in the proper variable for doing ubbc foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } if($enable_ubbc) { &DoUBBC; } $message =~ s~(\S{80})(?=\S)~$1\n~g; print <<"EOT"; EOT ; } print <<"EOT";
 $txt{'535'} $txt{'118'}
$usernamelink
$memberinfo
$star

$postinfo $userprofile[11]
$userprofile[13]$userprofile[12] $userprofile[8] $icqad   $userprofile[10] $yimon   $userprofile[9]
 $msub $txt{'30'}: $mydate

$message
$userprofile[5]
EOT if ($userprofile[19] ne "checked" || $settings[7] eq "Administrator" || $allow_hide_email ne 1) { print << "EOT"; $userprofile[4]$img{'email'}$profbutton EOT } else { print << "EOT"; $userprofile[4]$profbutton EOT } print << "EOT"; $img{'replyquote'}$menusep$img{'reply'}$menusep$img{'im_remove'}
EOT &footer; exit; } sub IMPost { if($username eq 'Guest') { &fatal_error($txt{'147'}); } my( @messages, $mfrom, $msubject, $mdate, $mmessage, $mip, $form_message, $form_subject ); $yytitle=$txt{'148'}; &header; if($INFO{'num'} ne "") { if($INFO{'caller'} == 1) { fopen(FILE, "$memberdir/$username.msg"); } else { fopen(FILE, "$memberdir/$username.outbox"); } @messages = ; fclose(FILE); ($mfrom, $msubject, $mdate, $mmessage, $mip) = split(/\|/,$messages[$INFO{'num'}]); $msubject =~ s/Re: //g; if($INFO{'quote'} == 1) { $mmessage =~ s/
/\n/g; $form_message =~ s/\[quote\](\S+?)\[\/quote\]//isg; $form_message =~ s/\[(\S+?)\]//isg; $form_message = "\n\n\[quote\]$mmessage\[/quote\]"; $form_subject = "Re: $msubject"; } if($INFO{'reply'} == 1) { $form_subject = "Re: $msubject"; } } if ($form_subject eq "") { $form_subject = "$txt{'24'}"; } print <<"EOT";
   $mbname
   $txt{'144'}
   $txt{'321'}
EOT print <<"EOT"; $img{'im_inbox'}$menusep$img{'im_outbox'}$menusep$img{'im_reload'}$menusep$img{'im_config'}
$img{'im_new'}
EOT if($enable_ubbc && $showyabbcbutt) { print << "EOT"; EOT } print << "EOT";
$txt{'150'}: $txt{'748'}
$txt{'70'}:
$txt{'252'}:
$txt{'297'}:
$txt{'469'}:
EOT &footer; exit; } sub IMPost2 { if($username eq 'Guest') { &fatal_error($txt{'147'}); } my( @imconfig, @ignore, $igname, $messageid, $subject, $message, @recipient, $ignored ); $subject = $FORM{'subject'}; $subject =~ s/\A\s+//; $subject =~ s/\s+\Z//; $message = $FORM{'message'}; if (length($message)>$MaxMessLen) { &fatal_error("$txt{'499'}"); } &fatal_error("$txt{'77'}") unless($subject); &fatal_error("$txt{'78'}") unless($message); $mmessage = $message; $msubject = $subject; $subject =~ s/\&/\&/g; $message =~ s/\&/\&/g; $subject =~ s/"/\"/g; $message =~ s/"/\"/g; $subject =~ s/ / \ /g; $message =~ s/ / \ /g; $subject =~ s//>/g; $subject =~ s/\|/\|/g; $message =~ s//>/g; $message =~ s/\t/ \  \  \ /g; $message =~ s/\cM//g; $message =~ s/\n/
/g; $message =~ s/\|/\|/g; if( $FORM{'waction'} eq 'previewim' ) { require "$sourcedir/Post.pl"; &Preview; } @multiple = split(/,/, $FORM{'to'}); foreach $db (@multiple) { chomp $db; $ignored = 0; $db =~ s/\A\s+//; $db =~ s/\s+\Z//; $db =~ s/[^0-9A-Za-z#%+,-\.@^_]//g; # Check Ignore-List if (-e("$memberdir/$db.imconfig")) { fopen(FILE, "$memberdir/$db.imconfig"); @imconfig = ; fclose(FILE); # Build Ignore-List $imconfig[0] =~ s/[\n\r]//g; $imconfig[1] =~ s/[\n\r]//g; @ignore = split(/\|/,$imconfig[0]); # If User is on Recipient's Ignore-List, show Error Message foreach $igname (@ignore) { #adds ignored user's name to array which error list will be built from later if ($igname eq $username) { push(@nouser, $db); $ignored = 1; } } } if (!(-e("$memberdir/$db.dat"))) { #adds invalid user's name to array which error list will be built from later push(@nouser, $db); $ignored = 1; } if(!$ignored) { # Create unique Message ID = Time & ProccessID $messageid = $^T.$$; # Add message to outbox if(-e("$memberdir/$username.outbox")) { fopen(FILE, ">>$memberdir/$username.outbox", 1); } else { fopen(FILE, ">$memberdir/$username.outbox", 1); } print FILE "$db|$subject|$date|$message|$messageid|$ENV{'REMOTE_ADDR'}\n"; fclose(FILE); # Send message to user fopen(FILE, ">>$memberdir/$db.msg"); print FILE "$username|$subject|$date|$message|$messageid|$ENV{'REMOTE_ADDR'}\n"; fclose(FILE); # Send notification if ($imconfig[1]==1) { fopen(FILE, "$memberdir/$db.dat"); @recipient = ; fclose(FILE); $mydate = &timeformat($date); $recipient[2] =~ s/[\n\r]//g; # get email address if ($recipient[2] ne "") { $fromname = $settings[1]; $txt{'561'} =~ s~SUBJECT~$msubject~g; $txt{'561'} =~ s~SENDER~$fromname~g; $txt{'561'} =~ s~DATE~$mydate~g; $txt{'562'} =~ s~SUBJECT~$msubject~g; $txt{'562'} =~ s~MESSAGE~$mmessage~g; $txt{'562'} =~ s~SENDER~$fromname~g; $txt{'562'} =~ s~DATE~$mydate~g; &sendmail($recipient[2],$txt{'561'},$txt{'562'}); } } } } #end foreach loop #if there were invalid usernames in the recipient list, these names are listed after all valid users have been IMed if (@nouser) { $badusers = join(", ", @nouser); &fatal_error("$badusers $txt{'747'}"); } $yySetLocation = qq~$cgi&action=im~; &redirectexit; } sub IMRemove { if($username eq 'Guest') { &fatal_error($txt{'147'}); } my( @messages, $a, $musername, $msub, $mdate, $mmessage, $messageid, $mip ); if ($INFO{'caller'} == 1) { fopen(FILE, "$memberdir/$username.msg"); } elsif ($INFO{'caller'} == 2) { fopen(FILE, "$memberdir/$username.outbox"); } @messages = ; fclose(FILE); if ($INFO{'caller'} == 1) { fopen(FILE, ">$memberdir/$username.msg", 1); } elsif ($INFO{'caller'} == 2) { fopen(FILE, ">$memberdir/$username.outbox", 1); } for ($a = 0; $a < @messages; $a++) { chomp $messages[$a]; # ONLY delete MSG with correct ID ($musername, $msub, $mdate, $mmessage, $messageid, $mip) = split(/\|/,$messages[$a]); # If Message-ID is < 100, user has used the old IM before if ($messageid < 100 ) { if($a ne $INFO{'id'}) { print FILE "$messages[$a]\n"; } } else { if($messageid ne "$INFO{'id'}") { print FILE "$messages[$a]\n"; } } } fclose(FILE); my $redirect = $INFO{'caller'} == 1 ? 'im' : 'imoutbox'; $yySetLocation = qq~$cgi&action=$redirect~; &redirectexit; } sub IMPreferences { if ($username eq 'Guest') { &fatal_error($txt{'147'}); } my( @imconfig, $sel0, $sel1 ); if (-e("$memberdir/$username.imconfig")) { fopen(FILE, "$memberdir/$username.imconfig"); @imconfig = ; fclose(FILE); } $imconfig[0] =~ s/[\n\r]//g; $imconfig[0] =~ s/\|/\n/g; $imconfig[1] =~ s/[\n\r]//g; if ($imconfig[1]) { $sel0=''; $sel1=' selected'; } else { $sel0=' selected'; $sel1=''; } $yytitle = "$txt{'323'}: $txt{'144'}"; &header; print <<"EOT";
   $mbname
   $txt{'144'}
   $txt{'323'}
EOT print <<"EOT"; $img{'im_inbox'} $img{'im_outbox'} $img{'im_new'} $img{'im_reload'}
$txt{'323'}
$txt{'325'}:
$txt{'326'}
$txt{'327'}:
 
EOT &footer; exit; } sub IMPreferences2 { if($username eq 'Guest') { &fatal_error($txt{'147'}); } my( $ignorelist, $notify ); $ignorelist = "$FORM{'ignore'}"; $notify = "$FORM{'notify'}"; $ignorelist =~ s~\A\n\s*~~; $ignorelist =~ s~\s*\n\Z~~; $ignorelist =~ s~\n\s*\n~\n~g; $ignorelist =~ s~[\n\r]~\|~g; $ignorelist =~ s~\|\|~\|~g; $notify =~ s~[\n\r]~~g; fopen(FILE, "+>$memberdir/$username.imconfig"); print FILE "$ignorelist\n$notify\n"; fclose(FILE); $yySetLocation = qq~$cgi&action=imprefs~; &redirectexit; } sub KillAll { if($username eq 'Guest') { &fatal_error($txt{'147'}); } if ($INFO{'caller'} == 1) { unlink("$memberdir/$username.msg"); $redirect = 'im'; } elsif ($INFO{'caller'} == 2) { unlink("$memberdir/$username.outbox"); $redirect = 'imoutbox'; } $yySetLocation = qq~$cgi&action=$redirect~; &redirectexit; } sub KillAllQuery { if($username eq 'Guest') { &fatal_error($txt{'147'}); } my( $query, $cgi2 ); if ($INFO{'caller'} == 1) { $yytitle .= $txt{'316'}; $imbox = $txt{'316'}; $cgi2 = "$cgi&action=imremoveall2&caller=1"; $cgi .= "&action=im"; } elsif ($INFO{'caller'} == 2) { $imbox = $txt{'320'}; $cgi2 = "$cgi&action=imremoveall2&caller=2"; $cgi .= "&action=imoutbox"; } $txt{'412'} =~ s~IMBOX~$imbox~g; $img{'im_delete'} =~ s~IMBOX~$imbox~g; &header; $yytitle = $txt{'412'}; print <<"EOT";
$txt{'412'}
$txt{'413'}
$txt{'163'} - $txt{'164'}
EOT &footer; exit; } 1;