#!/usr/bin/perl $discus_conf = '/home/sites/site140/web/discus_admin_10869941/discus.conf'; #Discus board new messages script #------------------------------------------------------------------------------- # DISCUS VERSION 3.10 COPYRIGHT NOTICE # # Discus 3.10 is copyright (c) 2000 by DiscusWare, LLC, all rights reserved. # The use of Discus is governed by the Discus License Agreement which is # available from the Discus WWW site at: # http://www.discusware.com/discus/license # # Pursuant to the Discus License Agreement, this copyright notice may not be # removed or altered in any way. #------------------------------------------------------------------------------- # To enable multiple selection of topics, you can enable one of # the following two options. However, this makes the interface # look not-so-good. # $multiple = "MULTIPLE SIZE=1"; # $multiple = "MULTIPLE"; # If you want the "do not use 7 day limit" enabled, uncomment this: # $nolimit = 1; # If you want more characters in the username, change this value: $max_name_chars = 20; #------------------------------------------------------------------------------ if (open (FILE, "$discus_conf")) { @file = ; close (FILE); foreach $line (@file) { if ($line =~ /^(\w+)=(.*)/) { $varname = $1; $value = $2; $value =~ s/\r//g; ${$varname} = $value; } } require "$admin_dir/source/src-board-subs-common"; } else { print "Content-type: text/html\n\n"; print "Script Execution Error\n"; print "\n"; print "

Script Execution Error

\n"; print "Discus scripts could not execute because the discus.conf file\n"; print "could not be opened."; print "

Reason: $!" if $!; print "

This generally indicates a setup error of some kind.\n"; print "Consult the Discus "; print "Resource Center for troubleshooting information.\n"; exit(0); } $version_number = join(".", $release_version, $free_revision) if !$pro; $version_number = join(".", $release_version, $pro_revision) if $pro; $version_number .= "(W95)" if ($platform eq "win95" || $win95); $version_number .= "(NT)" if ($platform eq "NT" || $NT); $version_number .= "*PRO*" if $pro; # This tries to keep long lines out of no frames interface $maxchar = 40; $maxchar = 25 if $interface eq "noframes"; &parse_form; &read_cookie; ($time) = &ex('get_date_time', "long"); &error_message($L{FILELOCKERROR}, $L{NOTICE_MAINTENANCEMODE}, 0, 1, 1) if $GLOBAL_OPTIONS{'maintenance'}; ######################################################### # These are now set through the Options Manager if ($GLOBAL_OPTIONS{'nmbold'} == 1 || $GLOBAL_OPTIONS{'nmbold'} eq "") { $bopen = ""; $bclose = ""; } else { $bopen = ""; $bclose = ""; } $CHECKED{'last'} = "CHECKED" if $GLOBAL_OPTIONS{'nm_default'} == 0; $CHECKED{'user'} = "CHECKED" if $GLOBAL_OPTIONS{'nm_default'} == 1; $CHECKED{'since'} = "CHECKED" if $GLOBAL_OPTIONS{'nm_default'} == 2; $CHECKED{'treeview'} = "CHECKED" if ($GLOBAL_OPTIONS{'nmtreev'} == 1 || $GLOBAL_OPTIONS{'nmtreev'} eq ""); ######################################################### # This is the static page that gets spit out if ($FORM{'method'} eq "" || ($FORM{'method'} eq "mynew" && $COOKIE{"user$COOKIE_ID"} eq "")) { $count = 0; if (open (TOP, "$message_dir/$board_topics_file")) { @top = ; close (TOP); @top = grep(//, @top); } else { &header; print "$fs

Invalid HTML Directory Specification

\n"; print "The HTML directory (or $board_topics_file file) could not be found.\n"; print "See your diagnostic"; print " script for more information.

\n"; print "Discus $version_number\n"; exit(0); } $count = 0; $last = 0; $lastline = ""; if ($GLOBAL_OPTIONS{'nmshowdate'} == 1 || $GLOBAL_OPTIONS{'nmshowdate'} eq "") { foreach $topic (@top) { $topic =~ m||; open (LOG, "$admin_dir/msg_index/$1-log.txt"); while () { next if !/\S/; $count += 1; @c = split(/;/, $_); if ($c[2] > $last) { $last = $c[2]; $lastline = $_; } } close (LOG); } } $option_string = ""; $when = (split(/;/, $lastline))[2]; if ($when ne "") { ($lasttime) = &ex('get_date_time', "long", $when); } $lasttime = "N/A" if $when eq ""; $counter = -1; $timer = time + ($GLOBAL_OPTIONS{'timezone'}*3600); if ($GLOBAL_OPTIONS{'usegmtime'} == 1) { $todays_day = (gmtime($timer))[6]; } else { $todays_day = (localtime($timer))[6]; } for($i = ($todays_day + 5); $i >= ($todays_day); $i -= 1) { $counter += 1; $option_string .= "


$L{NMSEARCHIN}   

EOF if ($GLOBAL_OPTIONS{'nm_show_since'} == 1 || $GLOBAL_OPTIONS{'nm_show_since'} eq "") { print < $L{NMWITHINLAST} 

EOF } if ($GLOBAL_OPTIONS{'nm_pw'} == 1 || $GLOBAL_OPTIONS{'nm_pw'} eq "") { print < $L{NMLASTCHECK}

EOF } if ($GLOBAL_OPTIONS{'nm_after'} == 1 || $GLOBAL_OPTIONS{'nm_after'} eq "") { print < $L{NMAFTER}  $ampmstr

EOF } print < $L{NMTREEVIEW}


$lps
EOF &ex('printuntil', 3, 17, 0, "", 0, 1); exit(0); } $cutoff = 0; $timestore = time; if ($FORM{'method'} eq 'redo') { $cutoff = $FORM{'cutoff'}; } elsif ($FORM{'method'} eq 'last') { $number = $FORM{'number'}; $factor = $FORM{'units'}; &error_message("Invalid Number", "The number you specified is invalid!") if $number <= 0; &error_message("Invalid Units", "What are you trying to do?") if $factor <= 0; $cutoff = $timestore; $cutoff -= $number * $factor * 60; } elsif ($FORM{'method'} eq 'since') { $timestore += (3600*$GLOBAL_OPTIONS{'timezone'}); if ($GLOBAL_OPTIONS{'usegmtime'} == 1) { ($sec, $min, $hour, $day, $nmonth, $year, $wday, $yday, $isdst) = gmtime($timestore); } else { ($sec, $min, $hour, $day, $nmonth, $year, $wday, $yday, $isdst) = localtime($timestore); } $midnighttoday = $timestore - $sec - (60 * $min) - (3600 * $hour); $midnightsys = $midnighttoday - (3600*$GLOBAL_OPTIONS{'timezone'}); $day = $FORM{'day'} + 2; $cutoff = $midnightsys - ($day * 86400); $cutoff += 43200 if $FORM{'ampm'} eq "pm"; $timearg = $FORM{'time'}; $timesep = $L{TIMESEPARATOR}; $timearg =~ s/[^\d$timesep]//g; ($hour, $min) = split(/$timesep/, $timearg); $hour = 0 if $hour == 12; $cutoff += ($min * 60) + ($hour * 3600); } elsif ($FORM{'method'} eq 'check' || $FORM{'method'} eq "mynew") { if ($FORM{'method'} eq "mynew") { $FORM{'username'} = $COOKIE{"user$COOKIE_ID"}; $my_new_feature = 1; $FORM{'where'} = "all" if $FORM{'where'} eq ""; } ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'}, "", "", 0, $FORM{'silent'}, 1); @result = split(/\n/, $result); @result_save = @result; &error_message($L{BPAUTHERROR}, $L{PROFILE_AUTHERROR_DESCR},0,1) if scalar(@result) == 0; if ($pro) { &ex('get_preferences', $FORM{'username'}, $FORM{'password'}); $FORM{'tree'} = "" if $PREF{'nm_view'} == 1; } $lastcheck = 0; foreach $result (@result_save) { chomp $result; ($file, $user, $pass, $foo, $foo, $foo, $foo, $lc, $therest) = split(/:/, $result); if ($lc =~ m|/|) { $lc = $`; $la = $'; } $lastcheck = $lc if $lc > $lastcheck; $password_save = $pass; } if ($lastcheck == 0) { $docut = "$L{NMNOCHECK}\n"; $cutoff = $timestore; $cutoff -= 1440 * 60 * 7; } else { $cutoff = $lastcheck; if ($timestore > ($cutoff + 604800) && $PREF{'show_all_nm'} == 0 && !$FORM{'nolimit'}) { $docut .= "$L{NMCHECKSEVENDAYS}

\n"; $cutoff = $timestore - 604800; } else { $docut .= "$L{NMYOULASTCHECKED} "; ($dt) = &ex('get_date_time', 'long', $cutoff); $docut .= $dt; $docut .= ".
\n"; } } if ($FORM{'silent'}) { $docut .= "$L{NMNOTRECORDED}\n"; } ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'}, "", "", 1, $FORM{'silent'}); } if ($pro) { &ex('get_preferences', 1); if ($FORM{'tree'} eq "ON" || $my_new_feature) { $FORM{'tree'} = "ON" if $FORM{'tree'} ne "no"; $FORM{'tree'} = "" if $PREF{'nm_view'} == 1; $FORM{'where'} = $PREF{'favorites'} if ($PREF{'last_favs'} == 1 && $PREF{'favorites'} =~ /\S/); } } $| = 1; undef @returned_list; undef %file; undef %msgindex; $counter = 0; undef %seen; &header; @topics = split(/,/, $FORM{'where'}); if ($FORM{'where'} eq "all") { undef @topics; open (HTML, "$message_dir/$board_topics_file"); @html = ; close (HTML); @x = grep(/^/, @html); foreach $line (@x) { $line =~ m||; push (@topics, $1); } } @topics = &ex('log_authorization', @topics) if $pro; foreach $topic (@topics) { $topic =~ s/\D//g; if (open(LOG, "$admin_dir/msg_index/$topic-log.txt")) { while () { next if !/^(\d+);([^;]*);/; chomp; ($what,$who,$when,$where,$how) = split(/;/, $_); if ($when != 0 && $when >= $cutoff) { $flag = 0; ($thistopic, $num) = split(/\//, $where); push(@returned_list, $_) if $flag == 0; $file{$where} .= "$_," if $flag == 0; $flag = 1 if $seen{$where} == 1; $seen{$where} = 1; $counter += 1 if $flag == 0; } } close (LOG); } } $tmp = $/; undef $/; foreach $topic (@topics) { open (TREE, "$admin_dir/msg_index/$topic-tree.txt"); $TT{$topic} = ; close (TREE); } $/ = $tmp; if ($max_newmessages && scalar(@returned_list) > $max_newmessages) { @rtl2 = sort sort_by_time @returned_list; @returned_list = splice(@rtl2, 0, $max_newmessages); } sub sort_by_time { my @aa = split(/;/, $a); my @bb = split(/;/, $b); return $bb[2] <=> $aa[2]; } open (TREE, "$admin_dir/tree.txt"); @tree = ; close (TREE); foreach $line (@tree) { @c = split(/\t/, $line); if ($TT{$c[1]} ne "") { $line = $TT{$c[1]}; delete $TT{$c[1]}; } } @TREE_STRUCTURE_FILE = split(/\n/, join("", @tree)); undef @result; foreach $line (@returned_list) { chomp $line; ($postindex, $who, $time, $where, $addr, $host, $message2, $who2) = split(/;/, $line); ($topic, $page) = split(/\//, $where); if (($ll) = grep(/^(\d+)\t$topic\t$page\t/, @TREE_STRUCTURE_FILE)) { $ll =~ s/\s+$//; @c = split(/\t/, $ll); if ($c[5] !~ m|Messages|) { $line = ""; next; } if ($c[5] =~ m|Archive| && $GLOBAL_OPTIONS{"skip_archives_nm"}) { $line = ""; next; } @x = split(/,/, $c[11]); if (!grep(/^$postindex$/, @x)) { $line = ""; next; } if ($subname{$where} eq "") { push (@result, $where); } $subname{$where} = &unescape($c[4]); $lm{$where} = $c[8]; $msgplace{$postindex} = $where; $msgtext{$postindex} = &unescape($message2); $msgindex{$where} = $c[11]; $postedby{$postindex} = &unescape($who2); $postedby{$postindex} =~ s/\s+$//; $postedwhen{$postindex} = $time; push (@msgid, $postindex); } else { $line = ""; next; } } undef %WHERE_ORDER; $c = 0; foreach $line (@TREE_STRUCTURE_FILE) { if ($line =~ m|^(\d+)\t(\d+)\t(\d+)\t|) { $c += 1; $WHERE_ORDER{"$2/$3"} = $c; } } @results = sort findorder (@result); sub findorder { ($first, $second) = ($a, $b); return 0 if $first eq $second; return 1 if $WHERE_ORDER{$first} > $WHERE_ORDER{$second}; return -1 if $WHERE_ORDER{$first} < $WHERE_ORDER{$second}; return 0; } if ($FORM{'redisplay'} ne "") { $FORM{'tree'} = "" if $FORM{'redisplay'} !~ /Tree/; $FORM{'tree'} = "ON" if $FORM{'redisplay'} =~ /Tree/; } &ex('printuntil', 1, 1, 0, "$L{NMRESULTSOFSEARCH}"); print "

$L{NMRESULTSOFSEARCH}
\n
\n"; $numnew = scalar(@results); print "$docut\n"; if ($numnew == 0) { print "$L{NMZERONEW}
\n"; &ex('printuntil', 3, 17, 0, "", 0, 1); exit(0); } elsif ($numnew == 1) { print "$L{NMONENEW}
\n"; } else { $l = $L{NMPLURALNEW}; $l =~ s/\%d/$numnew/g; print "$l
\n"; } &ex('printuntil', 3, 5, 0, "", 0, 1); if ($FORM{'tree'} ne "") { $browser = $ENV{'HTTP_USER_AGENT'}; if ($browser !~ /MSIE/) { if ($browser =~ m|Mozilla/(\d+)|) { $nsbug = 1 if ($1 < 4 && $interface eq "noframes"); } } $ie3 = 0; $ie3 = 1 if $ENV{'HTTP_USER_AGENT'} =~ m|MSIE 3\.|; $nsbug = 1 if $ie3; undef %seen; if (!$nsbug) { print "\n"; } } else { foreach $where (@results) { ($topic, $page) = split(/\//, $where); ($navbar) = &ex('get_navbar', $topic, $page, "nmnav", 0); $navbar =~ s/:\s+$//; print "$bopen"; print $navbar; print "$bclose\n"; @message = split(/\n/, $msgdata{$where}); print "
\n"; @msgind = split(/,/, $msgindex{$where}); foreach $post (@msgind) { $pn = $post; ($dateprint) = &ex('get_date_time', 'realshort', $postedwhen{$pn}); if ($postedby{$pn} ne "") { $postedby{$pn} =~ s/\([^\)]*\)//g; $postedby{$pn} =~ s/\s+$//; $by = &char_convert($postedby{$pn}, 1); $text = &char_convert($msgtext{$pn}, 1); $text =~ s//>/g; $l = $by; while ($l =~ m|&#(\d+);|) { $l = join("", $`, pack("c", $1), $'); } $l = substr($l, 0, $max_name_chars); $l = &char_convert($l, 1); $by = $l; print ""; print "$by: $dateprint: $text
\n"; $flag = 0; } } print "

\n"; } } print "


\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n" if $FORM{'tree'} eq ""; print "" if $FORM{'tree'} ne ""; print "" if $FORM{'tree'} eq ""; print "
\n"; &ex('printuntil', 7, 17, 0, "", 0, 1); exit(0); # END - FILE IS CORRECTLY UPLOADED #