############################################################################### # 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 # # =========================================================================== # # Re-written for Notify Once 2 by BHRA Webmaster. # ############################################################################### $notifyplver = "Notify Once 2.0"; sub Notify2 { if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } if($username eq 'Guest') { &fatal_error($txt{'138'}); } $thread = $INFO{'thread'}; fopen(FILE, "$memberdir/$username.not"); my $tmp_board_notify = || 0; my $tmp_thread_notify = || 0; fclose(FILE); chomp $tmp_board_notify; chomp $tmp_thread_notify; if ($thread eq "") {$filename = qq~$boardsdir/$currentboard.mail~; $notify_type = $tmp_board_notify;} else {$filename = qq~$datadir/$thread.mail~; $notify_type = $tmp_thread_notify;} fopen(FILE, "$filename"); @mails = ; fclose(FILE); fopen(FILE, ">$filename", 1) || &fatal_error("$txt{'23'} $filename"); print FILE "$settings[2]|0|$notify_type\n"; foreach $curmail (@mails) { my ($tmp_mail, $dummy) = split(/\|/,$curmail, 2); if(lc $settings[2] ne lc $tmp_mail) { print FILE $curmail; } } fclose(FILE); if ($thread eq "") {$yySetLocation = qq~$cgi~;} else {$yySetLocation = qq~$cgi;action=display;num=$thread;start=$INFO{'start'}~;} &redirectexit; } ############################################################################### sub Notify3 { if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } if($username eq "Guest") { &fatal_error("$txt{'138'}"); } $thread = $INFO{'thread'}; if ($thread eq "") {$filename = qq~$boardsdir/$currentboard.mail~;} else {$filename = qq~$datadir/$thread.mail~;} fopen(FILE, "$filename"); @mails = ; fclose(FILE); fopen(FILE, ">$filename", 1) || &fatal_error("$txt{'23'} $filename"); foreach $curmail (@mails) { my ($tmp_mail, $dummy) = split(/\|/,$curmail, 2); if(lc $settings[2] ne lc $tmp_mail) { print FILE $curmail; } } fclose(FILE); if (-z "$filename") { unlink("$filename"); } if ($thread eq "") {$yySetLocation = qq~$cgi~;} else {$yySetLocation = qq~$cgi;action=display;num=$thread;start=$INFO{'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" || $dummy2 eq "board") { if ($dummy2 eq "thread") {$filename = "$datadir/$threadno.mail";} else {$filename = "$boardsdir/$threadno.mail";} fopen(FILE, "$filename"); @mails = ; fclose(FILE); fopen(FILE, ">$filename") || &fatal_error("$txt{'23'} $threadno.mail"); foreach $curmail (@mails) { my ($tmp_mail, $dummy) = split(/\|/,$curmail, 2); if(lc $settings[2] ne lc $tmp_mail) { print FILE $curmail; } } fclose(FILE); if (-z "$filename") { unlink("$filename"); } } } # update profile with notification options if( $enable_board_notify == 3 || $enable_notification == 3) { fopen(FILE, "$memberdir/$username.not"); my $old_notify_board = ; my $old_notify_thread = ; fclose(FILE); chomp $old_notify_board; chomp $old_notify_thread; if( $enable_board_notify == 3 ) {$notify_board = $FORM{"notify_board"} ? 1 : 0;} else {$notify_board = $old_notify_board ? 1 : 0;} if( $enable_notification == 3 ) {$notify_thread = $FORM{"notify_thread"} ? 1 : 0;} else {$notify_thread = $old_notify_thread ? 1 : 0;} if ($notify_board ne $old_notify_board || $notify_thread ne $old_notify_thread) { fopen(FILE, ">$memberdir/$username.not", 1); print FILE "$notify_board\n"; print FILE "$notify_thread\n"; fclose(FILE); if ($notify_board ne $old_notify_board) {&replace_notifications($settings[2], $settings[2], $notify_board, 0);} if ($notify_thread ne $old_notify_thread) {&replace_notifications($settings[2], $settings[2], $notify_thread, 1);} } } $yySetLocation = qq~$cgi~; &redirectexit; } ############################################################################### sub ShowNotifications { if($username eq "Guest") { &fatal_error("$txt{'138'}"); } my(@dirdata, @boarddata, @datdata, $filename, $entry, @entries, $mnum, $dummy, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, @messages, @found_number, @found_subject, @found_date, @found_username, @found_board, $tmp_notify_board, $tmp_notify_thread); &LoadCensorList; # Load Censor List # Read all .mail-Files and search for username opendir (DIRECTORY,"$datadir"); @dirdata = readdir(DIRECTORY); closedir (DIRECTORY); unless ($enable_notification) {undef @dirdata;} @datdata = grep(/\.mail$/,@dirdata); foreach $filename (@datdata) { fopen(FILE, "$datadir/$filename"); @entries = ; fclose(FILE); foreach $entry (@entries) { my ($tmp_mail, $dummy) = split(/\|/,$entry, 2); if (lc $tmp_mail eq lc $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]); fopen(FILE, "$datadir/$mnum.data"); $dummy = ; $mboard = ; fclose(FILE); chomp $mboard; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } if ($mboard ne "") {$msub = qq~$msub~;} push(@found_number,$mnum); push(@found_subject,$msub); push(@found_date,$mdate); push(@found_username,$musername); push(@found_name,$mname); } } } opendir (DIRECTORY,"$boardsdir"); @boarddata = readdir(DIRECTORY); closedir (DIRECTORY); unless ($enable_board_notify) {undef @boarddata;} @datdata = grep(/\.mail$/,@boarddata); foreach $filename (@datdata) { fopen(FILE, "$boardsdir/$filename"); @entries = ; fclose(FILE); foreach $entry (@entries) { my ($tmp_mail, $dummy) = split(/\|/,$entry, 2); if (lc $tmp_mail eq lc $settings[2]) { ($boardid, $dummy) = split(/\./,$filename); fopen(FILE, "$boardsdir/$boardid.dat"); $bname = ; fclose(FILE); chomp $bname; push(@found_boardid,$boardid); push(@found_bname,$bname); } } } if( $enable_board_notify == 3 || $enable_notification == 3) { fopen(FILE, "$memberdir/$username.not"); $tmp_notify_board = ; $tmp_notify_thread = ; fclose(FILE); chomp $tmp_notify_board; chomp $tmp_notify_thread; } # Display all Entries $yymain .= qq~
~; if (@found_boardid != 0) {$yymain .= qq~ ~; } else {$yymain .= qq~~;} if (@found_number != 0) {$yymain .= qq~ ~; } else {$yymain .= qq~~;} if (@found_number == 0 && @found_boardid == 0 ) { $yymain .= qq~ ~; } else { $yymain .= qq~ ~; } $yymain .= qq~
$txt{'418'}

$bln_txt{'05a'}:

~; $counter = 0; foreach $entry (@found_boardid) { $yymain .= qq~ ~; $counter++; } if( $enable_board_notify == 3 ) { $nbl = $tmp_notify_board ? " checked" : ""; $yymain .= qq~ ~;} $yymain .= qq~
  $found_bname[$counter]

  $bln_txt{'13'}


$bln_txt{'05b'}:

~; $counter = 0; foreach $entry (@found_number) { &FormatUserName($found_username[$counter]); if ($found_username[$counter] ne "Guest") { $found_name[$counter] = qq~$found_name[$counter]~;} $found_date[$counter] = &timeformat($found_date[$counter], 1); if (-e "$datadir/$found_number[$counter].poll") {$ispoll = "$polltxt{'15'}: ";} else {$ispoll = ""} $yymain .= qq~ ~; $counter++; } if( $enable_notification == 3 ) { $ntl = $tmp_notify_thread ? " checked" : ""; $yymain .= qq~ ~;} $yymain .= qq~
  $ispoll$found_subject[$counter] - $txt{'109'} $found_name[$counter] $txt{'30'} $found_date[$counter]

  $bln_txt{'14'}


$txt{'414'}


~; if (@found_number != 0 || @found_boardid != 0 ) { $yymain .= qq~
($txt{'416'})
~;} $yytitle = "$txt{'417'}"; &template; exit; } ############################################################################### sub remove_notifications { my (@deademails) = (@_); my (@datdata, @boarddata, $tmp, $filename, $content, $content_old); opendir (DIRECTORY,"$datadir"); @datdata = grep {/\.mail$/} readdir(DIRECTORY); closedir (DIRECTORY); foreach (@datdata) { $_ = "$datadir/".$_;} opendir (DIRECTORY,"$boardsdir"); @boarddata = grep {/\.mail$/} readdir(DIRECTORY); closedir (DIRECTORY); foreach (@boarddata) { $_ = "$boardsdir/".$_;} push (@datdata, @boarddata); foreach $filename (@datdata) { $content = ''; $changed = 0; fopen(FILE, "+<$filename") || &fatal_error("$txt{'23'} $filename"); while () { $tmp = $_; my ($tmp_email, $dummy) = split(/\|/,$tmp, 2); foreach $old_email (@deademails) { if (lc $tmp_email eq lc $old_email) { $tmp = ""; $changed = 1; } } $content .= $tmp; } if ($changed == 1) { truncate(FILE,0); seek(FILE,0,0); print FILE $content; } fclose(FILE); if (-z "$filename") { unlink("$filename"); } } } ############################################################################### sub replace_notifications { my $old_email = $_[0]; my $new_email = $_[1]; my $new_notify = $_[2] ? 1 : 0; my $new_type = $_[3] ? 1 : 0; my (@datdata, @boarddata, $tmp, $filename, $content, $content_old); if ($new_type == 0) { opendir (DIRECTORY,"$boardsdir"); @boarddata = grep {/\.mail$/} readdir(DIRECTORY); closedir (DIRECTORY); foreach $filename (@boarddata) { $content = ''; $changed = 0; fopen(FILE, "+<$boardsdir/$filename") || &fatal_error("$txt{'23'} $boardsdir/$filename"); while () { $tmp = $_; chomp $tmp; my ($tmp_email, $tmp_reply, $tmp_notify) = split(/\|/,$tmp); if (lc $tmp_email eq lc $old_email) { $content .= "$new_email|$tmp_reply|$new_notify\n"; $changed = 1; } else { $content .= "$tmp\n"; }; } if ($changed == 1) { truncate(FILE,0); seek(FILE,0,0); print FILE $content; } fclose(FILE); if (-z "$boardsdir/$filename") { unlink("$boardsdir/$filename"); } } } else { opendir (DIRECTORY,"$datadir"); @datdata = grep {/\.mail$/} readdir(DIRECTORY); closedir (DIRECTORY); foreach $filename (@datdata) { $content = ''; $changed = 0; fopen(FILE, "+<$datadir/$filename") || &fatal_error("$txt{'23'} $datadir/$filename"); while () { $tmp = $_; chomp $tmp; my ($tmp_email, $tmp_reply, $tmp_notify) = split(/\|/,$tmp); if (lc $tmp_email eq lc $old_email) { $content .= "$new_email|$tmp_reply|$new_notify\n"; $changed = 1; } else { $content .= "$tmp\n"; }; } if ($changed == 1) { truncate(FILE,0); seek(FILE,0,0); print FILE $content; } fclose(FILE); if (-z "$datadir/$filename") { unlink("$datadir/$filename"); } } } } 1;