############################################################################### # InstantMessage.pl # ############################################################################### # # # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # # # Version: YaBB 1 Gold - SP 1.4 # # Released: December 2001; Updated November 25, 2004 # # Distributed by: http://www.yabbforum.com # # # # =========================================================================== # # # # Copyright (c) 2000-2004 YaBB (www.yabbforum.com) - All Rights Reserved. # # # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # # Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com # # Your source for web hosting, web design, and domains. # # # ############################################################################### $instantmessageplver = "1 Gold - SP 1.4"; sub IMIndex { if( $username eq 'Guest' ) { &fatal_error($txt{'147'}); } fopen(IM, "$memberdir/$username.msg"); @immessages = ; fclose(IM); $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); &LoadCensorList; # Load censor list. $sender = "im"; # Fix moderator showing in info $yymain .= qq~
   $mbname
   $txt{'144'}
   $txt{'316'}
~; if( @immessages ) { $yymain .= qq~ $img{'im_delete'}$menusep~; } $yymain .= qq~ $img{'im_outbox'}$menusep$img{'im_new'}$menusep$img{'im_reload'}$menusep$img{'im_config'}
~; unless( @immessages ) { $yymain .= qq~ ~; } @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; } if( $musername ne 'Guest' && ! $yyUDLoaded{$musername} && -e("$memberdir/$musername.dat") ) { # If user is not in memory, s/he must be loaded. &LoadUserDisplay($musername); } $usernamelink = qq~$musername~; if (!$useraccount{$musername}) {$usernamelink = qq~$musername~;} $mydate = &timeformat($mdate); $yymain .= qq~ ~; } if( @immessages ) { $yymain .= qq~
 $txt{'317'} $txt{'318'} $txt{'319'}  
$txt{'151'}
$mydate $usernamelink $msub $img{'im_remove'}
\n\n
~; } 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}}; $displayname = $userprofile[1]; $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]; } if (!$useraccount{$musername}) {$usernamelink=qq~$musername~; $memberinfo ="$txt{'783'}"; $displayname = $musername;} 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 &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $yymain .= qq~ ~; } $yymain .= qq~
 $txt{'29'} $txt{'118'}
$usernamelink
$memberinfo
~; if ($useraccount{$musername}) { $yymain .= qq~ $star

$userprofile[13]$userprofile[12]
$userprofile[8] $icqad   $userprofile[10] $yimon   $userprofile[9]

$userprofile[11] $postinfo ~; } $yymain .= qq~
 $msub $txt{'30'}: $mydate

$message
$userprofile[5]
~; if ($useraccount{$musername}) { if ($userprofile[19] ne "checked" || $settings[7] eq "Administrator" || $allow_hide_email ne 1) { $yymain .= qq~ $userprofile[4]$img{'email'}$profbutton ~; } else { $yymain .= qq~ $userprofile[4]$profbutton ~; } } $yymain .= qq~ ~; if ($useraccount{$musername}) {$yymain .= qq~$img{'replyquote'}$menusep$img{'reply'}~;} $yymain .= qq~ $menusep$img{'im_remove'}
~; $yytitle = $txt{'143'}; &template; 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); $sender = "im"; # Fix moderator showing in info # Read Membergroups fopen(FILE, "$vardir/membergroups.txt"); @membergroups = ; fclose(FILE); &LoadCensorList; # Load censor list. $yymain .= qq~
   $mbname
   $txt{'144'}
   $txt{'320'}
~; if( @ommessages ) { $yymain .= qq~ $img{'im_delete'}$menusep~; } $yymain .= qq~ $img{'im_inbox'}$menusep$img{'im_new'}$menusep$img{'im_reload'}$menusep$img{'im_config'}
~; # Display Message if there are no Messages in Users Outbox unless( @ommessages ) { $yymain .= qq~ ~; } @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; } if( $musername ne 'Guest' && ! $yyUDLoaded{$musername} && -e("$memberdir/$musername.dat") ) { # If user is not in memory, s/he must be loaded. &LoadUserDisplay($musername); } $usernamelink = qq~$musername~; if (!$useraccount{$musername}) {$usernamelink = qq~$musername~;} $mydate = &timeformat($mdate); $yymain .= qq~ ~; } # Output all messages if( @ommessages ) { $yymain .= qq~
 $txt{'317'} $txt{'324'} $txt{'319'}  
$txt{'151'}
$mydate $usernamelink$msub $img{'im_remove'}

~; } 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]; } if (!$useraccount{$musername}) {$usernamelink=qq~$musername~; $memberinfo ="$txt{'783'}"; $displayname = $musername;} $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; } &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $yymain .= qq~ ~; ; } $yymain .= qq~
 $txt{'535'} $txt{'118'}
$usernamelink
$memberinfo
~; if ($useraccount{$musername}) { $yymain .= qq~ $star

$userprofile[13]$userprofile[12]
$userprofile[8] $icqad   $userprofile[10] $yimon   $userprofile[9]

$userprofile[11] $postinfo ~; } $yymain .= qq~
 $msub $txt{'30'}: $mydate

$message
$userprofile[5]
~; if ($useraccount{$musername}) { if ($userprofile[19] ne "checked" || $settings[7] eq "Administrator" || $allow_hide_email ne 1) { $yymain .= qq~ $userprofile[4]$img{'email'}$profbutton ~; } else { $yymain .= qq~ $userprofile[4]$profbutton ~; } } $yymain .= qq~ ~; if ($useraccount{$musername}) {$yymain .= qq~$img{'replyquote'}$menusep$img{'reply'}~;} $yymain .= qq~ $menusep$img{'im_remove'}
~; $yytitle = $txt{'143'}; &template; exit; } sub IMPost { if($username eq 'Guest') { &fatal_error($txt{'147'}); } my( @messages, $mdate, $mip, $mmessage); if($INFO{'num'} ne "") { if($INFO{'caller'} == 1) { fopen(FILE, "$memberdir/$username.msg"); } else { fopen(FILE, "$memberdir/$username.outbox"); } @messages = ; fclose(FILE); ($mfrom, $sub, $mdate, $mmessage, $mip) = split(/\|/,$messages[$INFO{'num'}]); $sub =~ s/Re: //g; if($INFO{'quote'} == 1) { $message = $mmessage; $message =~ s/
/\n/g; $message =~ s/\[quote\](\S+?)\[\/quote\]//isg; $message =~ s/\[(\S+?)\]//isg; $message = "\[quote\]$message\[/quote\]\n"; if ($message =~ /\#nosmileys/isg) {$message =~ s/\#nosmileys//isg; $nscheck="checked";} $sub = "Re: $sub"; } if($INFO{'reply'} == 1) { $sub = "Re: $sub";} } if ($sub eq "") { $sub = "$txt{'24'}"; } $yymain .= qq~
   $mbname
   $txt{'144'}
   $txt{'321'}
$img{'im_inbox'}$menusep$img{'im_outbox'}$menusep$img{'im_reload'}$menusep$img{'im_config'}
~; $submittxt = "$txt{'148'}"; $destination = "imsend2"; $is_preview = 0; $post = "imsend"; $preview = "previewim"; $icon = "xx"; require "$sourcedir/Post.pl"; $yytitle = $txt{'148'}; &Postpage; &doshowims; &template; 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{'752'}") unless($FORM{'to'}); &fatal_error("$txt{'77'}") unless($subject); &fatal_error("$txt{'78'}") unless($message); $mmessage = $message; $msubject = $subject; &ToHTML($message); $message =~ s/\t/ \  \  \ /g; $message =~ s/\cM//g; $message =~ s/\n/
/g; if ($FORM{'ns'} eq "NS") {$message .= "#nosmileys";} if( $FORM{'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 ($igname eq "*") {push(@nouser, "$txt{'761'} $db $txt{'762'};"); $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|$user_ip\n"; fclose(FILE); unless ($sendedto =~ /\#$db\#/) { # Send message to user fopen(FILE, ">>$memberdir/$db.msg"); print FILE "$username|$subject|$date|$message|$messageid|$user_ip\n"; fclose(FILE); } $sendedto.="#$db#"; # 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(" $txt{'763'} ", @nouser); $badusers =~ s/; $txt{'763'}/;/; &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=''; } $yymain .= qq~
   $mbname
   $txt{'144'}
   $txt{'323'}
~; $yymain .= qq~ $img{'im_inbox'} $img{'im_outbox'} $img{'im_new'} $img{'im_reload'}
$txt{'323'}
$txt{'325'}:
$txt{'326'}
$txt{'327'}:
 
~; $yytitle = "$txt{'323'}: $txt{'144'}"; &template; 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 doshowims { my $tempdate; if($INFO{'num'} ne "") { chomp $immessages[$INFO{'num'}]; ($musername, $msub, $mdate, $message, $messageid, $mips) = split( /\|/, $immessages[$INFO{'num'}]); # Load Censor List &LoadCensorList; $yymain .= qq~

~; $tempdate = &timeformat($mdate); foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; } &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $yymain .= qq~
$txt{'319'}: $msub
$txt{'318'}: $musername$txt{'30'}: $tempdate
$message
\n ~; } } 1;