home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / www / mirrors / acheron / cgi-bin / discus_staff / board-newmessages.cgi < prev    next >
Text File  |  1999-01-29  |  27KB  |  790 lines

  1. #!/usr/bin/perl
  2. $discus_conf = '/usr/local/www/www.acheron.org/discus_admin_116439176/discus.conf';
  3. #Discus board new messages script
  4. #-------------------------------------------------------------------------------
  5. # This script is copyright (c) 1998 by DiscusWare, LLC, all rights reserved.
  6. # Its use is subject to the license agreement that can be found at the following
  7. # URL:  http://www.chem.hope.edu/discus/license
  8. #-------------------------------------------------------------------------------
  9. # If you want to change the default selection on the new messages
  10. # top page, you can do so here by commenting/uncommenting lines.
  11. $CHECKED{'last'} = "CHECKED";  # Search last x days/hours
  12. #$CHECKED{'user'} = "CHECKED";  # Search by username/password
  13. #$CHECKED{'since'} = "CHECKED"; # Search since 12:01 am ...
  14. # If you want the message tree view to be enabled by default, you
  15. # can define this variable
  16. $CHECKED{'treeview'} = "CHECKED";
  17. # To enable multiple selection of topics, you can enable one of
  18. # the following two options.  However, this makes the interface
  19. # look not-so-good.
  20. # $multiple =  "MULTIPLE SIZE=1";
  21. # $multiple =  "MULTIPLE";
  22. # If you want the "do not use 7 day limit" enabled, uncomment this:
  23. # $nolimit = 1;
  24. # If you want more characters in the username, change this value:
  25. $max_name_chars = 20;
  26. #------------------------------------------------------------------------------
  27. if (open (FILE, "$discus_conf")) {
  28.     @file = <FILE>;
  29.     close (FILE);
  30.     $evals = "";
  31.     foreach $line (@file) {
  32.         if ($line =~ /^(\w+)=(.*)/) {
  33.             $varname = $1;
  34.             $value = $2;
  35.             $value =~ s/'/\\'/g; $value =~ s/\r//g;
  36.             $evals .= "\$$varname='$value'; ";
  37.         }
  38.     }
  39.     eval($evals);
  40.     require "$admin_dir/source/src-board-subs-common";
  41. } else {
  42.     print "Content-type: text/html\n\n";
  43.     print "<HTML><HEAD><TITLE>Script Execution Error</TITLE></HEAD>\n";
  44.     print "<BODY BGCOLOR=#ffffff TEXT=#000000>\n";
  45.     print "<H1>Script Execution Error</H1>\n";
  46.     print "Discus scripts could not execute because the discus.conf file\n";
  47.     print "could not be opened.";
  48.     print "<P>Reason: <FONT COLOR=#ff0000><B>$!</B></FONT>" if $!;
  49.     print "<P>This generally indicates a setup error of some kind.\n";
  50.     print "Consult the <A HREF=\"http://www.chem.hope.edu/discus/rc\">Discus ";
  51.     print "Resource Center</A> for troubleshooting information.</BODY></HTML>\n";
  52.     exit(0);
  53. }
  54. $version_number = join(".", $release_version, $free_revision) if !$pro;
  55. $version_number = join(".", $release_version, $pro_revision) if $pro;
  56. $version_number .= "(W95)" if ($platform eq "win95" || $win95);
  57. $version_number .= "(NT)" if ($platform eq "NT" || $NT);
  58. $version_number .= "*PRO*" if $pro;
  59. # This tries to keep long lines out of no frames interface
  60. $maxchar = 40;
  61. $maxchar = 25 if $interface eq "noframes";
  62. &parse_form;
  63. &read_cookie;
  64. open (LOG, "$admin_dir/log.txt");
  65. @LOG = <LOG>;
  66. close (LOG);
  67. @LOG = reverse @LOG;
  68. ($time) = &ex('get_date_time', "long");
  69. #########################################################
  70. # This is the static page that gets spit out
  71. if ($FORM{'method'} eq "") {
  72.     $option_string = "";
  73.     foreach $logline (@LOG) {
  74.         ($what,$who,$when,$where,$anon) = split(/;/, $logline);
  75.         next if $what =~ /^D/;
  76.         last if $what !~ /^D/;
  77.     }
  78.     $count = scalar(@LOG);
  79.     $when = "" if $what =~ /^D/;
  80.     if ($when ne "") {
  81.         ($lasttime) = &ex('get_date_time', "long", $when);
  82.     }
  83.     $lasttime = "N/A" if $when eq "";
  84.     $counter = -1;
  85.     $todays_day = (localtime(time))[6];
  86.     for($i = ($todays_day + 5); $i >= ($todays_day); $i -= 1) {
  87.         $counter += 1;
  88.         $option_string .= "<OPTION VALUE=\"$counter\">";
  89.         if ($i <= 6) {
  90.             $ll = $L{NMLASTDAY};
  91.             $wday = $DAY[$i % 7];
  92.             $ll =~ s/\%weekday/$wday/g;
  93.             $option_string .= $ll;
  94.         } else {
  95.             $option_string .= $DAY[$i % 7];
  96.         }
  97.     }
  98.     $option_topic = "";
  99.     open (FILE, "$message_dir/board-topics.html");
  100.     @file = <FILE>;
  101.     close (FILE);
  102.     if ($pro) {
  103.         &ex('get_preferences', 1);
  104.         if ($PREF{'favorites'} ne "") {
  105.             $option_topic .= "<OPTION VALUE=\"$PREF{'favorites'}\" SELECTED>$L{MY_FAVORITES}\n";
  106.         }
  107.         $CHECKED{'treeview'} = "" if $PREF{'nm_view'};
  108.         if ($COOKIE{'user' . $COOKIE_ID} ne "") {
  109.             $CHECKED{'last'} = "";
  110.             $CHECKED{'user'} = "CHECKED";
  111.         }
  112.     }    
  113.     foreach $line (@file) {
  114.         if ($line =~ /<!-Top: (\d+)-!>/) {
  115.             $o = $1;
  116.             &extract("//$1/$1.$ext");
  117.             if (-e "$message_dir/$o") {
  118.                 $option_topic .= "<OPTION VALUE=\"$me_number\">$me_name\n";
  119.             } else {
  120.                 @auth = &ex('validate_auths', $o);
  121.                 $option_topic .= "<OPTION VALUE=\"$me_number\">$me_name\n" if grep(/^$o$/, @auth);
  122.             }                
  123.         }
  124.     }
  125.     &header;
  126.     $str = "$L{NMTITLE}";
  127.     &ex('printuntil',1, 1, 0, "$L{NMTITLE}");
  128.     print "$place\n";
  129.     $ts = $L{NMALLOF};
  130.     $ts =~ s/\%title/$titlej/g;
  131.     $ampmstr = "<SELECT NAME=\"ampm\" onChange=\"document.forms[0].method[2].checked = true\"><OPTION VALUE=\"am\" SELECTED>$L{AM}<OPTION VALUE=\"pm\">$L{PM}</SELECT>" if $L{HRCLOCK} == 12;
  132.     $lps = $L{NMLASTPOST};
  133.     $lps =~ s/\%date/$lasttime/g;
  134.     if ($nolimit == 1) {
  135.         $nolimit = "<INPUT TYPE=CHECKBOX NAME=nolimit VALUE=1";
  136.         $nolimit .= " CHECKED" if $PREF{'show_all_nm'} == 1;
  137.         $nolimit .= ">$L{NM_SHOW_ALL_NM}";
  138.     } else {
  139.         $nolimit = "";
  140.     }
  141.     $ucid = "user$COOKIE_ID";
  142.     $pcid = "rpwd$COOKIE_ID";
  143.     if ($COOKIE{$ucid}) {
  144.         $CHECKED{'last'} = "";
  145.         $CHECKED{'user'} = "CHECKED";
  146.     }
  147.     print <<EOF;
  148. <CENTER><FONT SIZE=+1><B>$L{NMTITLE}</B></FONT></CENTER>
  149. <HR>
  150. <FORM ACTION="$script_url/board-newmessages.$cgi_extension" METHOD=POST>
  151. $L{NMSEARCHIN} <SELECT NAME="where" $multiple>
  152. <OPTION VALUE="all">$ts
  153. $option_topic
  154. </SELECT>  <INPUT TYPE=SUBMIT VALUE="$L{NMSEARCHBUTTON}">
  155. <HR>
  156. <BR>
  157. <INPUT NAME="method" TYPE=radio VALUE="last" $CHECKED{'last'}>
  158. $L{NMWITHINLAST} 
  159. <INPUT NAME="number" VALUE="1" SIZE=3 onChange="document.forms[0].method[0].checked = true">
  160. <SELECT NAME="units" onChange="document.forms[0].method[0].checked = true">
  161. <OPTION VALUE="1">$L{NMMINUTES}
  162. <OPTION VALUE="60">$L{NMHOURS}
  163. <OPTION VALUE="1440" SELECTED>$L{NMDAYS}
  164. </SELECT>
  165. <P>
  166. <INPUT NAME="method" TYPE=radio VALUE="check" onClick=\"document.forms[0].username.focus()\" $CHECKED{'user'}>
  167. $L{NMLASTCHECK}<BR>
  168. <UL><TABLE><TR><TD><FONT FACE="$face" SIZE="$size">$L{PROFILE_USERNAME}</FONT></TD><TD><INPUT TYPE=TEXT NAME=username  VALUE="$COOKIE{$ucid}" SIZE=9 onChange=\"document.forms[0].method[1].checked = true\"></TD><TD><FONT FACE="$face" SIZE="$size">  $nolimit</FONT></TD></TR>
  169. <TR><TD><FONT FACE="$face" SIZE="$size">$L{PROFILE_PASSWORD}</FONT></TD><TD><INPUT TYPE=PASSWORD NAME=password SIZE=9 VALUE="$COOKIE{$pcid}"></TD><TD><FONT FACE="$face" SIZE="$size">  <INPUT TYPE=CHECKBOX NAME=silent VALUE=on onClick="document.forms[0].method[1].checked = true">$L{NMDONTREMEMBER}</FONT></TD></TR></TABLE>
  170. </UL>
  171. <P>
  172. <INPUT NAME="method" TYPE=radio VALUE="since" $CHECKED{'since'}>
  173. $L{NMAFTER} 
  174. <INPUT NAME="time" TYPE=text VALUE="$L{NMDEFAULTTIME}" SIZE=5 onChange="document.forms[0].method[2].checked = true">
  175. $ampmstr
  176. <SELECT NAME="day" onChange="document.forms[0].method[2].checked = true">
  177. <OPTION VALUE="-2">$L{NMTODAY}
  178. <OPTION VALUE="-1">$L{NMYESTERDAY}
  179. $option_string
  180. </SELECT>
  181. <P>
  182. <INPUT TYPE=CHECKBOX NAME=tree VALUE=1 $CHECKED{'treeview'}>
  183. $L{NMTREEVIEW}
  184. <BR>
  185. <HR>
  186. $lps
  187. <!-- Discus $version_number %$count% !$when!-->
  188. </FORM>
  189. EOF
  190.     &ex('printuntil', 3, 17, 0, "", 0, 1);
  191.     exit(0);
  192. }
  193. $cutoff = 0;
  194. $timestore = time;
  195. if ($FORM{'method'} eq 'redo') {
  196.     $cutoff = $FORM{'cutoff'};
  197. } elsif ($FORM{'method'} eq 'last') {
  198.     $number = $FORM{'number'};
  199.     $factor = $FORM{'units'};
  200.     &error_message("Invalid Number", "The number you specified is invalid!") if $number <= 0;
  201.     &error_message("Invalid Units", "What are you trying to do?") if $factor <= 0;
  202.     $cutoff = $timestore;
  203.     $cutoff -= $number * $factor * 60;
  204. } elsif ($FORM{'method'} eq 'since') {
  205.     ($sec, $min, $hour, $day, $nmonth, $year, $wday, $yday, $isdst) = localtime($timestore);
  206.     $midnighttoday = $timestore - $sec - (60 * $min) - (3600 * $hour);
  207.     $day = $FORM{'day'} + 2;
  208.     $cutoff = $midnighttoday - ($day * 86400);
  209.     $cutoff += 43200 if $FORM{'ampm'} eq "pm";
  210.     $timearg = $FORM{'time'};
  211.     $timesep = $L{TIMESEPARATOR};
  212.     $timearg =~ s/[^\d$timesep]//g;
  213.     ($hour, $min) = split(/$timesep/, $timearg);
  214.     $hour =- 12 if ($L{HRCLOCK} == 12 && $FORM{'ampm'} eq "pm");
  215.     $cutoff += ($min * 60) + ($hour * 3600);
  216. } elsif ($FORM{'method'} eq 'check') {
  217.     ($result) = &ex('verify_user_password', $FORM{'username'}, $FORM{'password'});
  218.     @result = split(/\n/, $result);
  219.     @result_save = @result;
  220.     &error_message($L{BPAUTHERROR}, $L{PROFILE_AUTHERROR_DESCR},0,1) if scalar(@result) == 0;
  221.     if ($pro) {
  222.         &ex('get_preferences', $FORM{'username'}, $FORM{'password'});
  223.         $FORM{'tree'} = "" if $PREF{'nm_view'} == 1;
  224.     }
  225.     $lastcheck = 0;
  226.     foreach $result (@result_save) {
  227.         ($file, $user, $pass, $foo, $foo, $foo, $foo, $lc, $therest) = split(/:/, $result);
  228.         $lastcheck = $lc if $lc > $lastcheck;
  229.         $password_save = $pass;
  230.     }
  231.     if ($lastcheck == 0) {
  232.         $docut = "$L{NMNOCHECK}\n";
  233.         $cutoff = $timestore;
  234.         $cutoff -= 1440 * 60 * 7;
  235.     } else {
  236.         $cutoff = $lastcheck;
  237.         if ($timestore > ($cutoff + 604800) && $PREF{'show_all_nm'} == 0 && !$FORM{'nolimit'}) {
  238.             $docut .= "$L{NMCHECKSEVENDAYS}<P>\n";
  239.             $cutoff = $timestore - 604800;
  240.         } else {
  241.             $docut .= "$L{NMYOULASTCHECKED} ";
  242.             ($dt) = &ex('get_date_time', 'long', $cutoff);
  243.             $docut .= $dt;
  244.             $docut .= ".<BR>\n";
  245.         }
  246.     }
  247.     if (!$FORM{'silent'}) {
  248.         $ctime = time;
  249.         &ex('save_profile_information', "", "", "", "", "", $ctime, "", @result_save);
  250.     } else {
  251.         $docut .= "$L{NMNOTRECORDED}\n";
  252.     }
  253. }
  254. if ($pro) {
  255.     &ex('get_preferences', 1);
  256.     if ($FORM{'tree'} eq "ON") {
  257.         $FORM{'tree'} = "" if $PREF{'nm_view'} == 1;
  258.         $FORM{'where'} = $PREF{'favorites'} if ($PREF{'last_favs'} == 1 && $PREF{'favorites'} =~ /\S/); 
  259.     }
  260. }
  261. $| = 1;
  262. undef @returned_list;
  263. undef %file;
  264. $counter = 0;
  265. undef %seen;
  266. @LOG = &ex('log_authorization', @LOG) if $pro;
  267. &header;
  268. foreach $line (@LOG) {
  269.     next if $line !~ /^(\d+);([^;]*);/; # Deleted and Old style
  270.     chop ($line) if $line =~ /\n$/;
  271.     ($what,$who,$when,$where,$how) = split(/;/, $line);
  272.     last if $when == 0;
  273.     last if $when < $cutoff;
  274.     $flag = 0;
  275.     ($thistopic, $num) = split(/\//, $where);
  276.     if ($FORM{'where'} ne "all") {
  277.         $flag = 1 if !grep(/^$thistopic$/, split(/,/, $FORM{'where'}));
  278.     }
  279.     push(@returned_list, $line) if $flag == 0;
  280.     $file{$where} .= "$line," if $flag == 0;
  281.     $flag = 1 if $seen{$where} == 1;
  282.     $seen{$where} = 1 if $flag == 0;
  283.     $counter += 1 if $flag == 0;
  284. }
  285. #########################################################
  286. # Build up data for the output page
  287. undef %subdata;
  288. undef %headstr;
  289. undef %msgdata;
  290. undef %topic;
  291. undef @topic_order;
  292. undef @result;
  293. undef @msgid;
  294. foreach $line (@returned_list) {
  295.     chop $line if $line =~ m|\n$|;
  296.     ($postindex, $who, $time, $where, $addr, $host, $message2, $who2) = split(/;/, $line);
  297.     if ($headstr{$where} eq "") {
  298.         ($topic, $page) = split(/\//, $where);
  299.         ($head, $color, $lm, $ann, $ann_src, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic, $page);
  300.         push (@result, $where) if $head ne "";
  301.         $headstr{$where} = $head;
  302.         $msgdata{$where} = $message;
  303.         $subdata{$where} = $sublist;
  304.         $lm{$where} = $lm;
  305.         @head = split(/\n/, $head);
  306.         foreach $l (@head) {
  307.             if ($l =~ m|<!--Topic: (\d+)/|) {
  308.                 $headdata{$where} = "$1,";
  309.             } elsif ($l =~ m|<!--Level (\d+): (\d+)/|) {
  310.                 $headdata{$where} .= "$2,";
  311.             }
  312.         }
  313.     }
  314.     push (@msgid, $postindex);
  315.     $msgplace{$postindex} = $where;
  316.     $msgtext{$postindex} = &unescape($message2);
  317.     $postedby{$postindex} = &unescape($who2); $postedby{$postindex} =~ s/\s+$//;
  318.     $postedwhen{$postindex} = $time;
  319. }
  320. open (TOP, "$html_dir/messages/board-topics.html");
  321. @top = <TOP>;
  322. close (TOP);
  323. foreach $line (@top) {
  324.     push (@topic_order, $1) if $line =~ m|<!-Top: (\d+)-!>|;
  325. }
  326. @results = sort findorder (@result); #Sort relevant subtopics
  327. sub findorder {
  328.     ($first, $second) = ($a, $b);
  329.     return 0 if $first eq $second;
  330.     ($t1, $p1) = split(/\//, $first);
  331.     ($t2, $p2) = split(/\//, $second);
  332.     if ($t1 != $t2) {
  333.         foreach $topic (@topic_order) {
  334.             return -1 if $topic == $t1;
  335.             return 1 if $topic == $t2;
  336.         }
  337.     }
  338.     @hd1 = split(/,/, $headdata{$first}); @hd1 = grep(/\S/, @hd1);
  339.     @hd2 = split(/,/, $headdata{$second}); @hd2 = grep(/\S/, @hd2);
  340.     return 1 if grep(/^$p1$/, @hd2); #2nd parent of 1st
  341.     return -1 if grep(/^$p2$/, @hd1); #1st parent of 2nd
  342.     $cpp = 0;
  343.     foreach $l (@hd1) {
  344.         last if !grep(/^$l$/, @hd2);
  345.         $cpp = $l;
  346.     }
  347.     for ($i = 0; $i <= scalar(@hd1); $i++) {
  348.         if ($hd1[$i] == $cpp) {
  349.             $pp1 = $hd1[$i+1];
  350.             $pp2 = $hd2[$i+1];
  351.             last;
  352.         }
  353.     }
  354.     $where = "$t1/$cpp";
  355.     if ($subdata{$where} eq "") {
  356.         ($head, $color, $lm, $ann, $ann_src, $sublist, $about, $about_src, $message, $message_src) = &get_page($t1, $cpp);
  357.         $headstr{$where} = $head;
  358.         $msgdata{$where} = $message;
  359.         $subdata{$where} = $sublist;
  360.         $lm{$where} = $lm;
  361.         @head = split(/\n/, $head);
  362.         foreach $l (@head) {
  363.             if ($l =~ m|<!--Topic: (\d+)/|) {
  364.                 $headdata{$where} = "$1,";
  365.             } elsif ($l =~ m|<!--Level (\d+): (\d+)/|) {
  366.                 $headdata{$where} .= "$2,";
  367.             }
  368.         }
  369.     } else {
  370.         $sublist = $subdata{$where};
  371.     }
  372.     foreach $line2 (split(/\n/, $sublist)) {
  373.         if ($line2 =~ m|<!-Top: (\d+)-!>|) {
  374.             return 1 if $1 == $pp2;
  375.             return -1 if $1 == $pp1;
  376.         }
  377.     }
  378.     return 0;
  379. }
  380. #########################################################
  381. # Print the output page
  382. if ($FORM{'redisplay'} ne "") {
  383.     $FORM{'tree'} = "" if $FORM{'redisplay'} !~ /Tree/;
  384.     $FORM{'tree'} = "ON" if $FORM{'redisplay'} =~ /Tree/;
  385. }
  386. &ex('printuntil', 1, 1, 0, "$L{NMRESULTSOFSEARCH}");
  387. print "<FONT SIZE=+1><CENTER><B>$L{NMRESULTSOFSEARCH}</B></CENTER></FONT>\n<HR>\n";
  388. $numnew = scalar(@results);
  389. print "$docut\n";
  390. if ($numnew == 0) {
  391.     print "$L{NMZERONEW}<HR>\n";
  392.     &ex('printuntil', 3, 17, 0, "", 0, 1);
  393.     exit(0);
  394. } elsif ($numnew == 1) {
  395.     print "$L{NMONENEW}<HR>\n";
  396. } else {
  397.     $l = $L{NMPLURALNEW};
  398.     $l =~ s/\%d/$numnew/g;
  399.     print "$l<HR>\n";
  400. }
  401. &ex('printuntil', 3, 5, 0, "", 0, 1);
  402. if ($FORM{'tree'} ne "") {
  403.     $browser = $ENV{'HTTP_USER_AGENT'};
  404.     if ($browser !~ /MSIE/) {
  405.         if ($browser =~ m|Mozilla/(\d+)|) {
  406.             $nsbug = 1 if ($1 < 4 && $interface eq "noframes");
  407.         }
  408.     }
  409.     $ie3 = 0;
  410.     $ie3 = 1  if $ENV{'HTTP_USER_AGENT'} =~ m|MSIE 3\.|;
  411.     $nsbug = 1 if $ie3;
  412.     undef %seen;
  413.     if (!$nsbug) {
  414.         print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
  415.         print "<!-- Hide from older browsers\n";
  416.         print "var i0 = '<IMG SRC=\"';\n";
  417.         print "var i1 = '$html_url/icons/tree_';\n";
  418.         print "var i2 = '.gif\" HEIGHT=16 WIDTH=20 ALIGN=TOP>';\n";
  419.         print "function crArray(leng) {\n";
  420.         print "  this.size = leng;\n";
  421.         print "  for(var i = 1; i <= leng; i++) {\n";
  422.         print "    this[i] = 0;\n";
  423.         print "  }\n";
  424.         print "}\n";
  425.         print "function p(ic, tl, ln, d) {\n";
  426.         print "    var pr = '';\n";
  427.         print "    for (var j = 0; j < ic.length; j++) {\n";
  428.         print "      m = ic.toString();\n";
  429.         print "      k = m.substring(j, 1+j);\n";
  430.         print "      pr = pr + i0 + i1 + k + i2;\n";
  431.         print "    }\n";
  432.         print "    if (ln != '') {\n";
  433.         print "      pr = pr + '<A ";
  434.         print "TARGET=_blank " if $PREF{'nm_newwindow'};        
  435.         print "HREF=\"' + ln + '\">';\n";
  436.         print "    }\n";
  437.         print "    pr = pr + tl;\n";
  438.         print "    if (ln != '') {\n";
  439.         print "      pr = pr + '</A>';\n";
  440.         print "    }\n";
  441.         print "    pr = pr + d;\n";
  442.         print "    pr = pr + '<BR>';\n";
  443.         print "    document.write(pr);\n";
  444.         print "}\n";
  445.     }
  446.     undef %seen; undef %seen2; undef %pr;
  447.     foreach $result (@results) {
  448.         @hd = split(/,/, $headdata{$result});
  449.         $result =~ m|^(\d+)/|; $topic = $1;
  450.         foreach $hd (@hd) {
  451.             $res = "$topic/$hd";
  452.             if ($headstr{$res} eq "") {
  453.                 ($head, $color, $lm, $ann, $ann_src, $sublist, $about, $about_src, $message, $message_src) = &get_page($topic, $hd);
  454.                 $headstr{$res} = $head;
  455.                 $msgdata{$res} = $message;
  456.                 $subdata{$res} = $sublist;
  457.                 $lm{$res} = $lm;
  458.             }
  459.             $seen{"$topic/$hd"} = 1;
  460.         }
  461.         $seen{$result} = 1;
  462.     }
  463.     foreach $res (keys(%seen)) {
  464.         $sublist = $subdata{$res};
  465.         $head = $headstr{$res};
  466.         @head = split(/\n/, $head);
  467.         ($hs) = grep(/^<!--Me: /, @head);
  468.         $hs =~ m|<!--Me: (\d+)/(.*)-->|;
  469.         $k = $2; $subname{$res} = &JavaScript_prepare($k, 1);
  470.         @subl = split(/\n/, $sublist);
  471.         $res =~ m|^(\d+)/|; $topic = $1;
  472.         foreach $s (@subl) {
  473.             if ($s =~ m|^<!-Top: (\d+)-!>|) {
  474.                 $lastnum{$res} = $1 if $seen{"$topic/$1"};
  475.             }
  476.         }
  477.     }
  478.     $last = $results[scalar(@results)-1];
  479.     $last =~ m|^(\d+)/|; $LAST_TOPIC = $1;
  480.     foreach $res (@results) {
  481.         $res =~ m|^(\d+)/|; $topic = $1;
  482.         @hs = split(/,/, $headdata{$res});
  483.         $c = 0; $t = $topic;
  484.         $parent = "";
  485.         foreach $l (@hs) {
  486.             $c += 1;
  487.             $res2 = "$topic/$l";
  488.             if (!$seen2{$res2}) {
  489.                 print "p('" if !$nsbug;
  490.                 $thisstr = "";
  491.                 if ($c == 1) {
  492.                     if (!$nsbug) {
  493.                         print "$thisstr", "g','<B>$subname{$res2}</B>',";
  494.                         if (-e "$message_dir/$res2.$ext") {
  495.                             print "'$message_url/$res2.$ext";
  496.                             print "?$lm{$res2}" if !$noqm;
  497.                         } else {
  498.                             print "'$script_url/board-auth.$cgi_extension?file=/$res2.$ext&lm=$lm{$res2}";
  499.                         }
  500.                         print "','');\n";
  501.                     } else {
  502.                         $lmstr = "?$lm{$res2}" if !$noqm;
  503.                         print "<IMG SRC=$html_url/icons/tree_g.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>";
  504.                         print "<A HREF=$html_url/messages/$res2.$ext$lmstr" if -e "$message_dir/$res2.$ext";
  505.                         print "<A HREF=$script_url/board-auth.$cgi_extension?file=/$res2.$ext&lm=$lmstr" if !-e "$message_dir/$res2.$ext";
  506.                         print " TARGET=_blank" if $PREF{'nm_newwindow'};
  507.                         print "><B>$subname{$res2}</B></A><BR>";
  508.                     }
  509.                     $seen2{$res2} = 1;
  510.                 } else {
  511.                     for ($i = 1; $i < ($c-1); $i++) {
  512.                         $thisstr .= "i" if $on{$i};
  513.                         $thisstr .= "j" if !$on{$i};
  514.                         if ($nsbug) {
  515.                             print "<IMG SRC=$html_url/icons/tree_i.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>" if $on{$i};
  516.                             print "<IMG SRC=$html_url/icons/tree_j.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>" if $on{$j};
  517.                         }                            
  518.                     }
  519.                     if ($l != $lastnum{$parent}) {
  520.                         $thisstr .= "e";
  521.                         if ($nsbug) {
  522.                             print "<IMG SRC=$html_url/icons/tree_e.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>" if $on{$j};
  523.                         }
  524.                         $on{$i} = 1;
  525.                     } else {
  526.                         $thisstr .= "f";
  527.                         if ($nsbug) {
  528.                             print "<IMG SRC=$html_url/icons/tree_f.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>" if $on{$j};
  529.                         }
  530.                         $on{$i} = 0;
  531.                     }
  532.                     if (!$nsbug) {
  533.                         print "$thisstr", "g','<B>$subname{$res2}</B>',";
  534.                         if (-e "$message_dir/$res2.$ext") {
  535.                             print "'$message_url/$res2.$ext";
  536.                             print "?$lm{$res2}" if !$noqm;
  537.                         } else {
  538.                             print "'$script_url/board-auth.$cgi_extension?file=/$res2.$ext&lm=$lm{$res2}";
  539.                         }
  540.                         print "', '');\n";
  541.                     } else {
  542.                         while ($thisstr =~ m|(\w)|g) {
  543.                             print "<IMG SRC=$html_url/icons/tree_$1.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>";
  544.                         }        
  545.                         print "<IMG SRC=$html_url/icons/tree_g.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>";
  546.                         $lmstr = "?$lm{$res2}" if !$noqm;
  547.                         print "<A HREF=$html_url/messages/$res2.$ext$lmstr" if -e "$message_dir/$res2.$ext";
  548.                         print "<A HREF=$script_url/board-auth.$cgi_extension?file=/$res2.$ext&lm=$lmstr" if !-e "$message_dir/$res2.$ext";
  549.                         print " TARGET=_blank" if $PREF{'nm_newwindow'};
  550.                         print "><B>$subname{$res2}</B></A><BR>";
  551.                     }
  552.                     $seen2{$res2} = 1;
  553.                 }
  554.             }
  555.             $thisstr =~ s/e$/i/;
  556.             $thisstr =~ s/f$/j/;
  557.             $parent = $res2;
  558.             if ($pr{$res2} == 0) {
  559.                 $pr{$res2} = 1;
  560.                 if (grep(/^$res2$/, values(%msgplace))) {
  561.                     $msg = $msgdata{$res2};
  562.                     if ($subdata{$res2} =~ m|<!-Top: (\d+)-!>|) {
  563.                         while ($subdata{$res2} =~ m|<!-Top: (\d+)-!>|g) {
  564.                             $o = $1;
  565.                             $has_subtopics{$res2} = 1 if $seen{"$topic/$o"};
  566.                         }
  567.                     }
  568.                     @msg = split(/\n/, $msg);
  569.                     undef @li1; undef @li2; undef @li3; undef @li4; undef @li5; $flag = 0;
  570.                     foreach $line (@msg) {
  571.                         if ($line =~ m|<!-Post: (\d+)-!>|) {
  572.                             $pn = $1;
  573.                             if (grep(/^$pn$/, @msgid)) {
  574.                                 push (@li1, $thisstr . "el");
  575.                                 push (@li4, $pn);
  576.                                 push (@li5, $postedwhen{$pn});
  577.                                 if ($postedby{$pn} ne "") {
  578.                                     $postedby{$pn} =~ s/\([^\)]*\)//g;
  579.                                     $postedby{$pn} =~ s/\s+$//;
  580.                                     $postedby{$pn} = &remove_html($postedby{$pn}, 1);
  581.                                     $msgtext{$pn} = &remove_html($msgtext{$pn}, 1);
  582.                                     $msgtext{$pn} = substr($msgtext{$pn}, 0, $maxchar);
  583.                                     push (@li2, &JavaScript_prepare($postedby{$pn}, 1));
  584.                                     push (@li3, &JavaScript_prepare($msgtext{$pn}, 1));
  585.                                 } else {
  586.                                     $flag = 1;
  587.                                 }
  588.                             } else {
  589.                                 $flag = 0;
  590.                             }
  591.                         } elsif ($flag > 0) {
  592.                             if ($line =~ m|<!-/Post:|) {
  593.                                 $flag = 0;
  594.                                 $p = &JavaScript_prepare($p, 1); $p .= " ";
  595.                                 $p =~ m|^(.{0,40})\s|;
  596.                                 $tempvar = $1; $tempvar = substr($tempvar, 0, $maxchar);
  597.                                 push (@li3, $tempvar);
  598.                             } elsif ($line =~ m|<FONT SIZE="-1">By <B>(.*)</B> on(.*)</FONT><P>|) {
  599.                                 $p = $1; $p =~ s/\([^\)]*\)//g; $p = &JavaScript_prepare($p, 1);
  600.                                 $p =~ s/\s+$//;
  601.                                 push (@li2, $p);
  602.                                 $p = "";
  603.                                 $flag = 2;
  604.                             } elsif ($flag == 2) {
  605.                                 $p .= $line;
  606.                             }
  607.                         }
  608.                     }
  609.                     $p = scalar(@li1);
  610.                     if ($p > 0) {
  611.                         $li1[$p-1] =~ s/el$/fl/ if !$has_subtopics{$res2};
  612.                     }
  613.                     for ($i = 0; $i < $p; $i++) {
  614.                         if (length($li2[$i]) > $max_name_chars) {
  615.                             $l = $li2[$i];
  616.                             while ($l =~ m|&#(\d+);|) {
  617.                                 $l = join("", $`, pack("c", $1), $');
  618.                             }
  619.                             $l = substr($l, 0, $max_name_chars);
  620.                             $l = &JavaScript_prepare($l, 1);
  621.                             $li2[$i] = $l;
  622.                         }
  623.                         if (!$nsbug) {
  624.                             print "p('", $li1[$i], "','<FONT SIZE=-1>", $li2[$i], "</FONT>',";
  625.                             if (-e "$message_dir/$res2.$ext") {
  626.                                 print "'$message_url/$res2.$ext";
  627.                                 print "?$lm{$res2}" if !$noqm;
  628.                             } else {
  629.                                 print "'$script_url/board-auth.$cgi_extension?file=/$res2.$ext&lm=$lm{$res2}";
  630.                             }
  631.                             print "#POST", $li4[$i], "','<FONT SIZE=-2>-";
  632.                             $pt = $li5[$i];
  633.                             ($dt) = &ex('get_date_time', 'realshort', $pt);
  634.                             print "$dt-";
  635.                             print $li3[$i], "</FONT>');\n";
  636.                         } else {
  637.                             while ($li1[$i] =~ m|(\w)|g) {
  638.                                 print "<IMG SRC=$html_url/icons/tree_$1.gif HEIGHT=16 WIDTH=20 ALIGN=TOP>";
  639.                             }
  640.                             print "<A HREF=$html_url/messages/$res2.$ext#POST$li4[$i] ";
  641.                             print "<A HREF=$script_url/board-auth.$cgi_extension?file=/$res2.$ext&lm=$lmstr#POST$li4[$i]" if !-e "$message_dir/$res2.$ext";
  642.                             print " TARGET=_blank" if $PREF{'nm_newwindow'} ;
  643.                             print ">" if -e "$message_dir/$res2.$ext";
  644.                             print "<FONT SIZE=-1>$li2[$i]</FONT></A>";
  645.                             print "<FONT SIZE=-2>-";
  646.                             $pt = $li5[$i];
  647.                             ($dt) = &ex('get_date_time', 'realshort', $pt);
  648.                             print "$dt-";
  649.                             print "$li3[$i]</FONT><BR>";
  650.                         }
  651.                     }
  652.                 }
  653.             }
  654.         }
  655.     }
  656.     if (!$nsbug) {
  657.         print "// -->\n";
  658.         print "</SCRIPT>\n";
  659.     }
  660. } else {
  661.     foreach $where (@results) {
  662.         ($topic, $page) = split(/\//, $where);
  663.         @head = split(/\n/, $headstr{$where});
  664.         ($topicstr) = grep(/<!--Topic: $topic/, @head);
  665.         $topicstr =~ m|<!--Topic: $topic/(.*)-->|;
  666.         $navbar = $1;
  667.         foreach $line (@head) {
  668.             if ($line =~ m|<!--Level \d+: \d+/(.*)-->|) {
  669.                 $navbar .= ": $1";
  670.             }
  671.         }
  672.         print "<A HREF=\"$message_url/$where.$ext" if -e "$message_dir/$where.$ext";
  673.         print "<A HREF=\"$script_url/board-auth.$cgi_extension?file=/$where.$ext&lm=$lm{$where}" if !-e "$message_dir/$where.$ext";
  674.         print "?$lm{$where}" if (!$noqm &&     -e "$message_dir/$where.$ext");
  675.         print " TARGET=_blank" if $PREF{'nm_newwindow'};
  676.         print "\"><B>";
  677.         print $navbar;
  678.         print "</B></A>\n";
  679.         @message = split(/\n/, $msgdata{$where});
  680.         $flag = 0;
  681.         print "<BLOCKQUOTE>\n";
  682.         foreach $line (@message) {
  683.             if ($line =~ m|<!-Post: (\d+)-!>|) {
  684.                 $post = $1; $pn = $post;
  685.                 ($dateprint) = &ex('get_date_time', 'realshort', $postedwhen{$pn});
  686.                 $flag = 1 if (grep(/^$post$/, @msgid));
  687.                 if ($postedby{$pn} ne "") {
  688.                     $postedby{$pn} =~ s/\([^\)]*\)//g;
  689.                     $postedby{$pn} =~ s/\s+$//;
  690.                     $by = &JavaScript_prepare($postedby{$pn}, 1);
  691.                     $text = &JavaScript_prepare($msgtext{$pn}, 1);
  692.                     $flag = 2 if $flag == 1;
  693.                 }
  694.             } elsif ($line =~ m|<!-/Post: (\d+)-!>|) {
  695.                 $pn = $1;
  696.                 $l = $by;
  697.                 while ($l =~ m|&#(\d+);|) {
  698.                     $l = join("", $`, pack("c", $1), $');
  699.                 }
  700.                 $l = substr($l, 0, $max_name_chars);
  701.                 $l = &JavaScript_prepare($l, 1);
  702.                 $by = $l;
  703.                 if ($flag > 0) {
  704.                     print "<A HREF=\"$message_url/$where.$ext" if -e "$message_dir/$where.$ext";
  705.                     print "<A HREF=\"$script_url/board-auth.$cgi_extension?file=/$where.$ext&lm=$lm{$where}" if !-e "$message_dir/$where.$ext";
  706.                     print "?$lm{$where}" if (!$noqm &&     -e "$message_dir/$where.$ext");
  707.                     print "#POST$pn\"";
  708.                     print " TARGET=_blank" if $PREF{'nm_newwindow'};
  709.                     print ">$by</A>: $dateprint: $text<BR>\n";
  710.                     $flag = 0;
  711.                 }
  712.             } elsif ($flag == 1 && $line =~ m|By <B>(.*)( [\(]).*</B>.*<B>(.*)</B>:</FONT><P>|i) {
  713.                 ($postby, $foo, $date) = ($1, $2, $3);
  714.                 $by = &remove_html($postby, 1);
  715.             } elsif ($flag == 1 && $line =~ m|<B>(.*)</B>.*<B>(.*)</B>:</FONT><P>|i) {
  716.                 ($postby, $date) = ($1, $2);
  717.                 $by = &remove_html($postby, 1);
  718.             } elsif ($line =~ m|^<HR>|) {
  719.                 next;
  720.             } elsif ($flag) {
  721.                 $line2 = &remove_html($line, 1);
  722.                 $line2 .= " ";
  723.                 $line2 =~ m|(.{0,40})\s|;
  724.                 $tempvar = $1; $tempvar = substr($tempvar, 0, $maxchar);
  725.                 $text = $tempvar;
  726.                 $flag = 3;
  727.             }
  728.         }
  729.         print "</BLOCKQUOTE><P>\n";
  730.     }
  731. }
  732. print "<HR>\n";
  733. print "<FORM ACTION=\"$script_url/board-newmessages.$cgi_extension\" METHOD=POST>\n";
  734. print "<INPUT TYPE=HIDDEN NAME=cutoff VALUE=\"$cutoff\">\n";
  735. print "<INPUT TYPE=HIDDEN NAME=method VALUE=\"redo\">\n";
  736. print "<INPUT TYPE=HIDDEN NAME=where VALUE=\"$FORM{'where'}\">\n";
  737. print "<INPUT TYPE=HIDDEN NAME=tree VALUE=1>\n" if $FORM{'tree'} eq "";
  738. print "<INPUT TYPE=SUBMIT VALUE=\"$L{NMOLDVIEWBUTTON}\">" if $FORM{'tree'} ne "";
  739. print "<INPUT TYPE=SUBMIT VALUE=\"$L{NMTREEVIEWBUTTON}\">" if $FORM{'tree'} eq "";
  740. print "</FORM>\n";
  741. &ex('printuntil', 7, 17, 0, "", 0, 1);
  742. exit(0);
  743. #########################################################
  744. # Miscellaneous Subroutines
  745. sub check_password {
  746.     local ($username, $guess) = @_;
  747.     local ($user, $ok, @passwd_line, $line, $pass, $test_pass, @group, $groupline);
  748.     local ($field1, $field2, @valid, @result);
  749.     undef (@result);
  750.     undef (@users);
  751.     open (PASSWD, "$admin_dir/users.txt") || &error_message("Verify Password Error", "Cannot open password file (users.txt) for reading!");
  752.     @users = <PASSWD>;
  753.     close (PASSWD);
  754.     @valid = @users;
  755.     open(PASSWD,"$admin_dir/passwd.txt") || &error_message("Verify Password Error", "Cannot open password file (passwd.txt) for reading!");
  756.     @passwd_line = <PASSWD>;
  757.     close(PASSWD);
  758.     $ok = "";
  759.     foreach $line (@passwd_line) {
  760.         ($user, $pass) = split(/:/, $line, 3);
  761.         if ($user eq $username) {
  762.             $test_pass = crypt($guess, $pass);
  763.             $ok = "";
  764.             $ok = "Yes" if $test_pass eq $pass;
  765.             $ok = "Yes" if $COOKIE{'cpwd' . $COOKIE_ID} eq crypt($pass, "cookie");
  766.             $ok = "No" if $guess eq "";
  767.             $ok = "No" if $pass eq "";
  768.             push (@result, "passwd:$line") if $ok eq "Yes";
  769.         }
  770.     }
  771.     open(PASSWD,"$admin_dir/users.txt") || &error_message("Verify Password Error", "Cannot open password file (users.txt) for reading!");
  772.     @passwd_line = <PASSWD>;
  773.     close(PASSWD);
  774.     $ok = "";
  775.     foreach $line (@passwd_line) {
  776.         chop ($line) if $line =~ /\n/;
  777.         ($user, $pass, $foo, $foo, $foo, $foo, $foo, $group_test) = split(/:/, $line);
  778.         if ($user eq $username) {
  779.             $test_pass = crypt($guess, $pass);
  780.             $ok = "";
  781.             $ok = "Yes" if $test_pass eq $pass;
  782.             $ok = "No" if $guess eq "";
  783.             $ok = "Yes" if $COOKIE{'cpwd' . $COOKIE_ID} eq crypt($pass, "cookie");
  784.             $ok = "No" if $pass eq "";
  785.             push (@result, "users:$line") if $ok eq "Yes";
  786.         }
  787.     }
  788.     return @result;
  789. }
  790.