# FILE: src-board-subs-10 #------------------------------------------------------------------------------- # This script is copyright (c) 1998 by DiscusWare, LLC, all rights reserved. # Its use is subject to the license agreement that can be found at the following # URL: http://www.chem.hope.edu/discus/license #------------------------------------------------------------------------------- #---SEPARATOR---# sub compare_profiles { local ($input) = @_; @input = split(/\n/, $input); local ($line, $file, $user, $pass, $email, $fullname, $edit, $notify, $lastcheck, $EMAIL_FORCE); foreach $line (@input) { ($file, $user, $pass, $email, $fullname, $edit, $notify, $lastcheck) = split(/:/, $line); if ($edit == 2) { $EMAIL_FORCE = $email; } } $line = shift(@input); ($file, $user, $pass, $email, $fullname, $edit, $notify, $lastcheck) = split(/:/, $line); $email = $EMAIL_FORCE if $EMAIL_FORCE; @emt = split(/,/, $notify); foreach $l (@emt) { if ($l =~ m|^(\d+)/|) { $l = $1; } } $notify = join(",", @emt); $e{$email} = 1; $f{$fullname} = 1; $n{$notify} = 1; foreach $line (@input) { ($file, $user, $pass, $email, $fullname, $edit, $notify, $lastcheck) = split(/:/, $line); $email = $EMAIL_FORCE if $EMAIL_FORCE; @emt = split(/,/, $notify); foreach $l (@emt) { if ($l =~ m|^(\d+)/|) { $l = $1; } } $notify = join(",", @emt); return 1 if !$n{$notify}; return 1 if !$e{$email}; return 1 if !$f{$fullname}; } return 0; } #---SEPARATOR---# #REQ:printuntil sub display_profile_differences { local ($username, $password, $input) = @_; @input = split(/\n/, $input); open (TOP, "$message_dir/board-topics.html"); @top = ; close (TOP); @tpc = grep(/|) { $t = $1; &extract("//$t/$t.$ext"); $topic{$t} = &remove_html($topic_name); } } &header; &printuntil(1, 1, 0, $L{PROFILE_SYNC_TITLE}); print "
$L{PROFILE_SYNC_TITLE}
\n"; print "
\n"; print $L{PROFILE_SYNC_DESCR}; print "

\n"; $ct = 0; foreach $line (@input) { $line =~ s/\n$//; ($file, $user, $pass, $email, $fullname, $edit, $notify, $last, $group) = split(/:/, $line); @emt = split(/,/, $notify); foreach $l (@emt) { if ($l =~ m|^(\d+)/|) { $l = $1; } } $notify = join(",", @emt); print "\n"; } print "
\n" if $ct == 0; print " " if $ct == 1; print "
" if $ct == 2; $ct += 1; $ct = 1 if $ct >= 3; print "
\n"; print "
\n"; print "\n"; print "$L{PROFEDIT_INFO}
\n"; print "\u$user
\n"; print "$email
\n"; print "$fullname

\n"; print "$L{PROFEDIT_EMAILNOTIFY}
\n"; foreach $line_n (split(/,/, $notify)) { print "- ", substr($topic{$line_n}, 0, 30) if $topic{$line_n} ne ""; print "..." if length($topic{$line_n}) > 30; print "
\n" if $topic{$line_n} ne ""; } print "- $L{PROFILE_MYPOSTS}
\n" if grep(/^0$/, split(/,/, $notify)); print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; &printuntil(3, 17, 0, "", 0, 1); exit(0); } #---SEPARATOR---# sub data_recovery { &header; print "Data Recovery\n"; print '$fs\n"; print "
Data Recovery
\n"; print "
\n"; if (open (TOP, "$message_dir/board-topics.html")) { @top = ; close (TOP); } else { if (open (TOP, ">$message_dir/board-topics.html")) { print TOP "\n"; close (TOP); } else { print "The problem is that the script cannot read the board-topics.html file,\n"; print "probably because your specification of the HTML directory is not correct.\n"; print "The reason the system cannot read the file is: $!.

"; print "If this is something to the effect of "No such file or directory"\n"; print "then you need to correct your setting of the HTML directory by editing your\n"; print "discus.conf file.

\n"; print ""; exit(0); } } if (!grep(/^/, @top)) { print "The data recovery utility has detected that the topics page has been\n"; print "corrupted, probably due to editing the file with an HTML editor.\n"; print "

This message could also occur if you have not ever created any topics\n"; print "on your board.

\n"; print "

\n"; print "
$fs"; print "You have two options for recovery:

\n"; print "Salvage Page\n"; print "

    This will attempt to save as much information as possible from your\n"; print "page (such as topic names, descriptions, last modified times, and so\n"; print "on). Depending on the extent of corruption, this may or may not find\n"; print "any topics. We recommend that you use this option first, and if it does\n"; print "not work, use the regeneration option below.

\n"; print "Regenerate Page\n"; print "

    This will regenerate all of the topics on the topics page, but you\n"; print "will lose all topic descriptions, the main message, and anything else\n"; print "that ordinarily is displayed on the top page. We recommend this option\n"; print "only in those cases where "Salvage Page" fails.

\n"; print "\n"; print "

\n"; print "\n"; print "\n"; print "
\n"; print "\n"; exit(0); } print "The data recovery utility allows you to fix pages which have been corrupted\n"; print "or inadvertantly deleted from your board. In most cases, subtopic data can\n"; print "be re-created by analyzing the other files in the topic directory. However,\n"; print "the text of any messages is permanently lost unless you restore from a backup.

\n"; print "

\n"; print "
$fs"; print "Select the name of the topic that contains the corrupted page from the list\n"; print "below. If you want the Data Recovery procedure to automatically fix the\n"; print "corrupted file for you, make sure "Automically Fix Errors" is checked.\n"; print "

Topic name: \n"; print "

Automatically Fix Errors\n"; print "

\n"; print "

\n"; print "\n"; print "\n"; print "
\n"; print "\n"; exit(0); } #---SEPARATOR---# sub data_recovery_action { local ($topic, $autofix) = @_; $topic =~ s/\D//g; $page =~ s/\D//g; if (!-e "$message_dir/$topic" && !-e "$secdir/$topic") { &error_message("Topic Specification Error", "The requested topic does not have its own subdirectory."); } undef %head_content; undef %parent; undef %sub_content; if (-e "$message_dir/$topic") { opendir(MESSAGEDIR, "$message_dir/$topic"); } else { opendir(MESSAGEDIR, "$secdir/$topic"); } undef @filelist; while ($file = readdir(MESSAGEDIR)) { push (@filelist, $file); } @filelist = grep(/^(\d+)\.$ext$/, @filelist); undef @corrupt; foreach $file (@filelist) { $file =~ s/\D//g; ($head, $color, $lm, $announce, $announce_src, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic, $file); $head{$file} = $head; $wf = $file if $head ne ""; $color_works = $color if $head ne ""; $sublist{$file} = $sublist; push (@corrupt, $file) if $head eq ""; } foreach $file (keys(%head)) { $head = $head{$file}; if ($head =~ m||) { $p = $1; $parent{$file} = $p; if ($head{$p} eq "") { push (@corrupt, $p) if !grep(/^$p$/, @corrupt); } else { $wf = $file; } } $st = $sublist{$file}; @st = split(/\n/, $st); @st = grep(/|; $sl = $1; if ($head{$sl} eq "") { push (@corrupt, $sl) if !grep(/^$sl$/, @corrupt); } $parent{$sl} = $file; } } $fixed = 0; undef @fixedpage; $sls = ""; if (scalar(@corrupt)) { foreach $f (@corrupt) { if ($f == $topic) { if ($wf != 0) { ($head, $color, $lm, $announce, $announce_src, $sublist, $about, $about_src, $message, $message_src) = &get_page($f, $wf); @h = split(/\n/, $head{$wf}); @h = grep(!/^|; push (@h, ""); $fixedname{$f} = $2; push (@h, ""); $fixed += 1; push (@fixed, $f); } } else { foreach $key (keys(%parent)) { $fixedit = 0; if ($parent{$key} == $f) { @h = split(/\n/, $head{$key}); @h = grep(!/^|; push (@h, ""); $fixedname{$f} = $3; @h = grep(!/^"); } else { push (@h, ""); } $fixed += 1; push (@fixed, $f); $fixedit = 1; push (@h, ""); last; } } if ($fixedit == 0) { $mlp1 = $ml + 1; $p = $parent{$f}; @h = split(/\n/, $head{$p}); @h = grep(!/^"); push (@h, ""); push (@h, ""); push (@h, ""); $fixed += 1; push (@fixed, $f); $fixedit = 1; $fixedname{$f} = "$this_name"; } } $h = join("\n", @h); foreach $key (keys(%parent)) { if ($parent{$key} == $f) { $head{$key} =~ m||; $me_number = $1; $me_name = $2; ($ts) = &ex('get_date_time', 'short'); $sls .= "
  • "; $sls .= "$me_name $ts
  • \n"; } } &set_page($topic, $f, $h, $color_works, "", "", "", $sls, "", "", "", "") if $autofix; } } &header; print "Data Recovery Report\n"; print '$fs\n"; print "

    Data Recovery Report
    \n"; print "
    \n"; if (scalar(@corrupt) == 0) { print "The data recovery utility was not able to find any corrupted pages in\n"; print "this topic. If any page has become corrupted, you should either delete\n"; print "that page or regenerate it by making a change to it using one of the\n"; print "administrative tools.\n"; } else { print "The data recovery utility detected ", scalar(@corrupt), " corrupted page"; print "s" if scalar(@corrupted) > 1; print " in this topic.\n"; print "Of these errors, $fixed "; print "were" if ($fixed != 1 && $autofix); print "was" if ($fixed == 1 && $autofix); print "can be" if !$autofix; print " fixed.

    \n"; if ($fixed > 0 && $autofix) { print "Note that the subtopics on the pages that were fixed will likely be in\n"; print "a different order than they were before the page was lost. Thus, you\n"; print "should access the Page Manager to reorder the subtopics if necessary.\n"; print "

    \n"; } if ($autofix) { print "The following pages were fixed:

    \n"; } else { print "The following pages can be fixed:

    \n"; print "

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
    \n"; } } print "\n"; exit(0); } #---SEPARATOR---# sub data_recovery_top { local ($option) = @_; if ($FORM{'rectype'} == 2) { opendir(DIR, "$message_dir"); undef @dir; while ($dir = readdir(DIR)) { push (@dir, $dir) if $dir =~ m|^(\d+)$|; } closedir(DIR); opendir(DIR, "$secdir"); while ($dir = readdir(DIR)) { push (@dir, $dir) if $dir =~ m|^(\d+)$|; } closedir(DIR); open (FILE, ">$message_dir/board-topics.html"); foreach $line (@dir) { print FILE "\n"; } close (FILE); } ($bgcolor, $text, $link, $vlink, $alink, $font, $size, $bg) = &ex('extract_colorsonly', 1); &ex('change_board_colors', $bgcolor, $text, $link, $vlink, $alink, $font, $size, $bg, 0, -45); open (FILE, "$admin_dir/frontpage_conf.txt"); @file = ; close (FILE); foreach $line (@file) { if ($line =~ m|^(\w+)=(\d+)|) { $FORM{$1} = $2; } } if ($FORM{'Bold'}) { $boldon = 1; } else { $boldon = 0; } if ($FORM{'Group'}) { $groupon = 1; } else { $groupon = 0; } if ($FORM{'Date'}) { $dateon = 1; } else { $dateon = 0; } if ($FORM{'Logo'}) { $logoon = 1; } else { $logoon = 0; } &ex('change_board_toppage', $boldon, $groupon, $dateon, $logoon); &ex('board_manager', $FORM{"username"}); exit(0); exit(0); } #---SEPARATOR---# sub auto_configure_email { # This automatically configures e-mail notification if the email.txt file does # not contain the necessary information. # If email.txt is good, we exit if (open(EMAIL, "$admin_dir/email.txt")) { @email = ; close (EMAIL); if (grep(/^command_line=/, @email)) { return 1; } } undef %EMT_params; # See if there is a send_mail.conf file if (open(SMC, "$admin_dir/send_mail.conf")) { @smc = ; close (SMC); undef @res; foreach $line (@smc) { $line =~ s/#(.*)//; $line =~ s/^\s+//; $line =~ s/\s+$//; next if $line !~ /\S/; next if $line =~ /^#/; $line =~ s/\s+/ /g; push (@res, $line); } foreach $line (@res) { $line =~ m|^(\w+)\s?=\s?(.*)|; ($varname, $param) = ($1, $2); $P{$varname} = $param; } if ($P{'program_path'}) { $EMT_params{'command_line'} = "| $P{'program_path'}"; $EMT_params{'mail_program'} = $P{'program_path'}; if ($P{'command_line'}) { $EMT_params{'command_line'} .= " $P{'command_line'}"; $EMT_params{'commandline'} = $P{'command_line'}; } } if ($P{'from'}) { if ($P{'from'} =~ m|([\w\-\+\.]+)\@([\w\-\+\.]+)|) { $EMT_params{'fromaddr'} = "$1\@$2"; $EMT_params{'fromname'} = join("", $`, $'); $EMT_params{'fromname'} =~ s/[^\w\s]//g; } else { $EMT_params{'fromname'} = $P{'from'}; $EMT_params{'fromaddr'} = ""; } } else { $EMT_params{'fromname'} = $titlej; $EMT_params{'fromaddr'} = ""; } if ($P{'subject'}) { $EMT_params{'static'} = $P{'subject'}; } else { $EMT_params{'static'} = "E-mail Notification of Post"; } if ($P{'from_name'}) { if ($P{'from_name'} =~ m|<(.*)>|) { $EMT_params{'fromaddress'} = 0; $EMT_params{'fromaddress_prefix'} = $1; $EMT_params{'fromaddress_switch'} = ""; $EMT_params{'input_stream'} .= "$1: \$FROM\n"; } else { $EMT_params{'fromaddress'} = 1; $EMT_params{'fromaddress_prefix'} = ""; $EMT_params{'fromaddress_switch'} = "-$P{'from_name'}"; $EMT_params{'command_line'} .= " -$P{'from_name'} '\$FROM'"; } } if ($P{'subj'}) { if ($P{'subj'} =~ m|<(.*)>|) { $EMT_params{'subjectaddress'} = 0; $EMT_params{'subjectaddress_prefix'} = $1; $EMT_params{'subjectaddress_switch'} = ""; $EMT_params{'input_stream'} .= "$1: \$SUBJECT\n"; } else { $EMT_params{'subjectaddress'} = 1; $EMT_params{'subjectaddress_prefix'} = ""; $EMT_params{'subjectaddress_switch'} = "-$P{'subj'}"; $EMT_params{'command_line'} .= " -$P{'subj'} '\$SUBJECT'"; } } if ($P{'to'}) { if ($P{'to'} =~ m|<(.*)>|) { $EMT_params{'toaddress'} = 0; $EMT_params{'toaddress_prefix'} = $1; $EMT_params{'toaddress_switch'} = ""; $EMT_params{'input_stream'} .= "$1: \$TO\n"; } else { $EMT_params{'toaddress'} = 1; $EMT_params{'toaddress_prefix'} = ""; $EMT_params{'toaddress_switch'} = "-$P{'to'}" if $P{'to'} ne ""; $EMT_params{'command_line'} .= " -$P{'to'} '\$TO'" if $P{'to'} ne ""; $EMT_params{'command_line'} .= " \$TO" if $P{'to'} eq ""; } } } if ($EMT_params{'mail_program'} eq "") { if ($mailprog =~ m|/sendmail|) { $EMT_params{'command_line'} = "| $mailprog -t"; $EMT_params{'mail_program'} = $mailprog; $EMT_params{'commandline'} = "-t"; $EMT_params{'toaddress'} = 0; $EMT_params{'toaddress_prefix'} = "TO:"; $EMT_params{'toaddress_switch'} = ""; $EMT_params{'fromaddress'} = 0; $EMT_params{'fromaddress_prefix'} = "FROM:"; $EMT_params{'fromaddress_switch'} = ""; $EMT_params{'subjectaddress'} = 0; $EMT_params{'subjectaddress_prefix'} = "SUBJECT:"; $EMT_params{'subjectaddress_switch'} = ""; $EMT_params{'input_stream'} = "TO: \$TO\nFROM: \$FROM\nSUBJECT: \$SUBJECT\n"; } elsif ($mailprog =~ m|/mail|) { $EMT_params{'command_line'} = "| $mailprog -s '\$SUBJECT' \$TO"; $EMT_params{'mail_program'} = $mailprog; $EMT_params{'commandline'} = ""; $EMT_params{'toaddress'} = 1; $EMT_params{'toaddress_prefix'} = "TO:"; $EMT_params{'toaddress_switch'} = ""; $EMT_params{'fromaddress'} = 2; $EMT_params{'fromaddress_prefix'} = ""; $EMT_params{'fromaddress_switch'} = ""; $EMT_params{'subjectaddress'} = 1; $EMT_params{'subjectaddress_prefix'} = ""; $EMT_params{'subjectaddress_switch'} = "-s"; } } if ($EMT_params{'mail_program'} eq "") { @sp = ("/usr/bin", "/bin", "/usr/sbin", "/sbin", "/usr/local/bin", "/usr/local/sbin", "/usr/contrib/bin", "/usr/contrib/sbin", "/usr/lib", "/lib", "/etc", "/"); foreach $p (@sp) { if (-x "$p/sendmail") { $EMT_params{'command_line'} = "| $p/sendmail -t"; $EMT_params{'mail_program'} = "$p/sendmail"; $EMT_params{'commandline'} = "-t"; $EMT_params{'toaddress'} = 0; $EMT_params{'toaddress_prefix'} = "TO:"; $EMT_params{'toaddress_switch'} = ""; $EMT_params{'fromaddress'} = 0; $EMT_params{'fromaddress_prefix'} = "FROM:"; $EMT_params{'fromaddress_switch'} = ""; $EMT_params{'subjectaddress'} = 0; $EMT_params{'subjectaddress_prefix'} = "SUBJECT:"; $EMT_params{'subjectaddress_switch'} = ""; $EMT_params{'input_stream'} = "TO: \$TO\nFROM: \$FROM\nSUBJECT: \$SUBJECT\n"; last; } } } if ($EMT_params{'mail_program'} eq "") { @sp = ("/usr/bin", "/bin", "/usr/sbin", "/sbin", "/usr/local/bin", "/usr/local/sbin", "/usr/contrib/bin", "/usr/contrib/sbin", "/usr/lib", "/lib", "/etc", "/"); foreach $p (@sp) { if (-x "$p/mail") { $EMT_params{'command_line'} = "| $p/mail -s '\$SUBJECT' \$TO"; $EMT_params{'mail_program'} = "$p/mail"; $EMT_params{'commandline'} = ""; $EMT_params{'toaddress'} = 1; $EMT_params{'toaddress_prefix'} = "TO:"; $EMT_params{'toaddress_switch'} = ""; $EMT_params{'fromaddress'} = 2; $EMT_params{'fromaddress_prefix'} = ""; $EMT_params{'fromaddress_switch'} = ""; $EMT_params{'subjectaddress'} = 1; $EMT_params{'subjectaddress_prefix'} = ""; $EMT_params{'subjectaddress_switch'} = "-s"; } } } $EMT_params{'1message'} = 0; $EMT_params{'sendtext'} = 1; $EMT_params{'tempfile'} = 0; $EMT_params{'subjectline'} = 0; if ($EMT_params{'fromaddr'} eq "") { if ($contact =~ m|"; } else { $fromstring = "\"$EMT_params{'fromname'}\" <$EMT_params{'fromaddr'}>"; } $EMT_params{'command_line'} =~ s/\$FROM/$fromstring/g; $EMT_params{'input_stream'} =~ s/\$FROM/$fromstring/g; $EMT_params{'static'} = "E-mail Notification of Post" if $EMT_params{'static'} eq ""; $EMT_params{'input_stream'} = &escape($EMT_params{'input_stream'}); &lock("$admin_dir/email.txt"); open (EMAIL, ">$admin_dir/email.txt"); foreach $key (keys(%EMT_params)) { print EMAIL "$key=$EMT_params{$key}\n"; } close (EMAIL); &unlock("$admin_dir/email.txt"); } #---SEPARATOR---# sub admin_from_here { if (open(HTML, "$html_dir/admin.html")) { @html = ; close (HTML); } else { &seturl("$html_url/admin.html"); exit(0); } foreach $line (@html) { if ($line =~ m|board-admin-menuonly.$cgi_extension|) { $line = join("", $`, $&, "?startfrom=$FORM{'startfrom'}", $'); } } &header; print @html; exit(0); }