############################################################################### # Notify.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 1 Gold - SP 1.3 # # Released: December 2001; Updated April 6, 2003 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2003 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 # ############################################################################### $notifyplver = "1 Gold - SP 1.3"; sub Notify { if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } if($username eq "Guest") { &fatal_error("$txt{'138'}"); } $isonlist = 0; # Check, if User already gets a notification if(-e "$datadir/$INFO{'thread'}.mail"){ fopen(FILE, "$datadir/$INFO{'thread'}.mail"); @mails = ; fclose(FILE); foreach $curmail (@mails) { $curmail =~ s/[\n\r]//g; if($settings[2] eq "$curmail") { $isonlist = 1; } } } if ($isonlist){ $yymain .= qq~
$txt{'125'}
$txt{'212'}
$txt{'163'} - $txt{'164'}
~; } else { $yymain .= qq~
$txt{'125'}
$txt{'126'}
$txt{'163'} - $txt{'164'}
~; } $yytitle = "$txt{'125'}"; &template; exit; } sub Notify2 { if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } if($username eq 'Guest') { &fatal_error($txt{'138'}); } $thread = $INFO{'thread'}; $start = $INFO{'start'} ne '' ? $INFO{'start'} : 9999999; if(-e ("$datadir/$thread.mail")){ fopen(FILE, "$datadir/$thread.mail"); @mails = ; fclose(FILE); } fopen(FILE, ">$datadir/$thread.mail", 1) || &fatal_error("$txt{'23'} $thread.mail"); print FILE "$settings[2]\n"; if(@mails){ foreach $curmail (@mails) { $curmail =~ s/[\n\r]//g; if($settings[2] ne $curmail) { print FILE "$curmail\n"; } } } fclose(FILE); $yySetLocation = qq~$cgi;action=display;num=$thread;start=$start~; &redirectexit; } sub Notify3 { if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } if($username eq "Guest") { &fatal_error("$txt{'138'}"); } $thread = $INFO{'thread'}; $start = $INFO{'start'} ne '' ? $INFO{'start'} : 9999999; fopen(FILE, "$datadir/$thread.mail"); @mails = ; chomp; fclose(FILE); chomp $mails[0]; chomp $mails[1]; # if there is only one entry and this is the address which is to remove, remove the file at all if(($mails[1] eq '') && ($settings[2] eq $mails[0])) { unlink("$datadir/$thread.mail"); } else { fopen(FILE, ">$datadir/$thread.mail", 1) || &fatal_error("$txt{'23'} $thread.mail"); foreach $curmail (@mails) { $curmail =~ s/[\n\r]//g; if($settings[2] ne "$curmail") { print FILE "$curmail\n"; } } fclose(FILE); } $yySetLocation = qq~$cgi;action=display;num=$thread;start=$start~; &redirectexit; } sub Notify4 { if($username eq "Guest") { &fatal_error("$txt{'138'}"); } my( $variable, $dummy, $dummy2, $threadno, @mails, $curmail ); foreach $variable (keys %FORM) { $dummy = $FORM{$variable}; ($dummy2,$threadno) = split(/-/,$variable); if ($dummy2 eq "thread") { fopen(FILE, "$datadir/$threadno.mail"); @mails = ; chomp; fclose(FILE); chomp $mails[0]; chomp $mails[1]; # if there is only one entry and this is the address which is to remove, remove the file at all if(($mails[1] eq '') && ($settings[2] eq $mails[0])) { unlink("$datadir/$threadno.mail"); } else { fopen(FILE, ">$datadir/$threadno.mail") || &fatal_error("$txt{'23'} $threadno.mail"); foreach $curmail (@mails) { $curmail =~ s/[\n\r]//g; if($settings[2] ne $curmail) { print FILE "$curmail\n"; } } fclose(FILE); } } } &ShowNotifications; } sub ShowNotifications { if($username eq "Guest") { &fatal_error("$txt{'138'}"); } my(@dirdata,@datdata,$filename,$entry,@entries,$mnum,$dummy,$msub,$mname,$memail,$mdate,$musername,$micon,$mattach,$mip,$mmessage,@messages,@found_number,@found_subject,@found_date,@found_username); # Read all .mail-Files and search for username opendir (DIRECTORY,"$datadir"); @dirdata = readdir(DIRECTORY); closedir (DIRECTORY); @datdata = grep(/mail/,@dirdata); # Load Censor List &LoadCensorList; foreach $filename (@datdata) { fopen(FILE, "$datadir/$filename"); @entries = ; fclose(FILE); foreach $entry (@entries) { $entry =~ s/[\n\r]//g; if ($entry eq $settings[2]) { ($mnum, $dummy) = split(/\./,$filename); fopen(FILE, "$datadir/$mnum.txt"); @messages = ; fclose(FILE); ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage) = split(/\|/,$messages[0]); push(@found_number,$mnum); push(@found_subject,$msub); push(@found_date,$mdate); push(@found_username,$musername); push(@found_name,$mname); } } } # Display all Entries $yymain .= qq~
$txt{'418'}

~; if (@found_number==0) { $yymain .= "$txt{'414'}

 "; } else { foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $found_subject[$counter] =~ s~\Q$tmpa\E~$tmpb~gi; } $yymain .= qq~
~; $counter=0; foreach $entry (@found_number) { &FormatUserName($found_username[$counter]); $yymain .= "~; $yymain .= qq~\n~; $counter++; } $yymain .= "\n"; $yymain .= qq~~; $yymain .= "
$txt{'415'}:
 
"; $yymain .= qq~$found_subject[$counter] $txt{'525'} $found_name[$counter]

$txt{'416'}
 
    

 \n"; } $yymain .= qq~
~; $yytitle = "$txt{'417'}"; &template; exit; } sub remove_notifications { my (@deademails, @maildir, $filename, $content, $content_old) = (@_); opendir (DIRECTORY,"$datadir"); @maildir = grep {/\.mail$/} readdir(DIRECTORY); closedir (DIRECTORY); foreach $filename (@maildir) { $content = ''; fopen(MYFILE, "+<$datadir/$filename") || &fatal_error("$txt{'23'} $filename"); while () { $content .= $_; } $content_old = $content; foreach (@deademails) { $content =~ s/$_(?:\r\n|\r|\n)//ig; } if (length($content) > 0) { if ($content ne $content_old) { truncate(MYFILE,0); seek(MYFILE,0,0); print MYFILE $content; fclose(MYFILE); $done .= "$filename\n"; } else { fclose(MYFILE); } } else { fclose(MYFILE); unlink("$datadir/$filename"); } } } sub replace_notifications { my ($old_email, $new_email, @maildir, $filename, $content, $content_old) = (shift, shift); opendir (DIRECTORY,"$datadir"); @maildir = grep {/\.mail$/} readdir(DIRECTORY); closedir (DIRECTORY); foreach $filename (@maildir) { $content = ''; fopen(MYFILE, "+<$datadir/$filename") || &fatal_error("$txt{'23'} $filename"); while () { $content .= $_; } $content_old = $content; $content =~ s/$old_email/$new_email/ig; if (length($content) > 0) { if ($content ne $content_old) { truncate(MYFILE,0); seek(MYFILE,0,0); print MYFILE $content; fclose(MYFILE); } else { fclose(MYFILE); } } else { fclose(MYFILE); unlink("$datadir/$filename"); } } } 1;