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 / hirez / cgi-bin / discus / board-admin-1.cgi next >
Text File  |  1999-02-12  |  15KB  |  342 lines

  1. #!/usr/bin/perl
  2. $discus_conf = '/usr/local/www/www.hirez.org/discus_admin_149349189/discus.conf';
  3. #Discus board administration script (board-admin-1.cgi)
  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 (open (FILE, "$discus_conf")) {
  10.     @file = <FILE>;
  11.     close (FILE);
  12.     $evals = "";
  13.     foreach $line (@file) {
  14.         if ($line =~ /^(\w+)=(.*)/) {
  15.             $varname = $1;
  16.             $value = $2;
  17.             $value =~ s/'/\\'/g; $value =~ s/\r//g;
  18.             $evals .= "\$$varname='$value'; ";
  19.         }
  20.     }
  21.     eval($evals);
  22.     require "$admin_dir/source/src-board-subs-common";
  23. } else {
  24.     print "Content-type: text/html\n\n";
  25.     print "<HTML><HEAD><TITLE>Script Execution Error</TITLE></HEAD>\n";
  26.     print "<BODY BGCOLOR=#ffffff TEXT=#000000>\n";
  27.     print "<H1>Script Execution Error</H1>\n";
  28.     print "Discus scripts could not execute because the discus.conf file\n";
  29.     print "could not be opened.";
  30.     print "<P>Reason: <FONT COLOR=#ff0000><B>$!</B></FONT>" if $!;
  31.     print "<P>This generally indicates a setup error of some kind.\n";
  32.     print "Consult the <A HREF=\"http://www.chem.hope.edu/discus/rc\">Discus ";
  33.     print "Resource Center</A> for troubleshooting information.</BODY></HTML>\n";
  34.     exit(0);
  35. }
  36. require "$admin_dir/source/src-board-subs-admin";
  37. &parse_form;
  38. &read_cookie;
  39. #-------------------------------------------------------------------------------
  40. # PAGE MANAGER ACTIONS AND OTHER RELATED FUNCTIONS
  41. #-------------------------------------------------------------------------------
  42. if ($FORM{'action'} eq 'add_subtopic') {
  43.     &check_passwd;
  44.     &extract ($FORM{'HTTP_REFERER'});
  45.     &verify_owner($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit this page!");
  46.     &error_message("Add Subtopic Error", "You did not specify a title for the new subtopic!") if $FORM{'subtopic'} eq "";
  47.     ($newtitle) = &ex("webtags", $FORM{'subtopic'},3);
  48.     &error_message("Add Subtopic Error", "Formatting tags returned the following error: <P>$newtitle") if $newtitle =~ /<H3>Formatting/i;
  49.     $param = "Sublist" if $FORM{'pagetype'} eq "privateindex";
  50.     $param = "SublistCreate" if $FORM{'pagetype'} eq "publicindex";
  51.     $param = "MessagesAdd" if $FORM{'pagetype'} eq "message";
  52.     $target = "Main" if $FORM{'linktype'} eq "rightframe";
  53.     $target = "_parent" if $FORM{'linktype'} eq "top";
  54.     $target = "_blank" if $FORM{'linktype'} eq "new";
  55.     $param = "LINK" if $FORM{'type'} eq "link";
  56.     if ($param eq "LINK") {
  57.         $url = $FORM{'url'};
  58.         &error_message('Add Subtopic Error', "The URL you specified was not valid") if $FORM{'url'} eq "";
  59.     }
  60.     ($newnum_number) = &ex("add_page", $newtitle,$param,$url,$target);
  61.     ($dt) = &ex("get_date_time", "short");
  62.     ($ts) = &ex("get_date_time", "long");
  63.     $ts =~ s/\W//g;
  64.     &ex("update_time", $topic_number, $newnum_number, $me_number, $ts, $dt);
  65.     $append = "?username=$FORM{'username'}";
  66.     &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"}) if ($FORM{'jumpin'} == 0 || $param eq "LINK");
  67.     &ex("page_mgr_2", "//$topic_number/$newnum_number.$ext", $FORM{"username"}) if $FORM{'jumpin'} == 1;
  68.     exit(0);
  69. }
  70. if ($FORM{'action'} eq "subtopics") {
  71.     &check_passwd;
  72.     &extract($FORM{'HTTP_REFERER'});
  73.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit this topic!");
  74.     if ($FORM{'SELECTION'} =~ /^delete(\w+)/) {
  75.         $todo = $1;
  76.         if ($todo eq "all") {
  77.             $todo = $FORM{'MARK'};
  78.         }
  79.         &ex("remove_page", $topic_number, $me_number, $todo);
  80.         &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  81.     } elsif ($FORM{'SELECTION'} =~ /move(\w+)/) {
  82.         if ($1 =~ /^(\d+)$/) {
  83.             $tomove = $1;
  84.             $plural = ""; $singular = "a ";
  85.         } else {
  86.             $tomove = $FORM{'MARK'};
  87.             $plural = "s"; $singular = "";
  88.         }
  89.         &ex('move_subtopic_form', $topic_number, $me_number, $FORM{'username'}, $plural, $singular, $FORM{'HTTP_REFERER'});
  90.         exit(0);
  91.     } elsif ($FORM{'SELECTION'} =~ /properties(\d+)/) {
  92.         $torename = $1;
  93.         if ($torename =~ /^0/) {
  94.             $torename =~ s/^0//g;
  95.             &ex("rename_link_form", $FORM{"HTTP_REFERER"},$torename,$FORM{"username"});
  96.         } else {
  97.             &ex("rename_subtopic_form", $FORM{"HTTP_REFERER"}, $torename, $FORM{"username"});
  98.         }
  99.         exit(0);
  100.     } elsif ($FORM{'SELECTION'} =~ /reorder/) {
  101.         undef @data;
  102.         undef @datakeys;
  103.         foreach $key (keys(%FORM)) {
  104.             $key2 = $key;
  105.             $keystr .= "$key2=$FORM{$key2}<BR>";
  106.             if ($key2 =~ /^ORDER/) {
  107.                 $key2 =~ s/^ORDER//g;
  108.                 $key2 =~ s/^0//g;
  109.                 push (@data, $key2);
  110.                 push (@dataval, $FORM{$key});
  111.             }
  112.         }
  113.         @array = @data[sort {$dataval[$a] <=> $dataval[$b]} $[..$#data];
  114.         $arraystr = join(":", @array);
  115.         &ex("reorder_subtopics", $FORM{"HTTP_REFERER"}, $arraystr);
  116.         &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  117.     }
  118. }
  119. if ($FORM{'action'} eq 'rename_a_subtopic' || $FORM{'action'} eq 'rename_a_link') {
  120.     &check_passwd;
  121.     &extract ($FORM{'HTTP_REFERER'});
  122.     &verify_owner ($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permissions to rename subtopics on this page!");
  123.     ($newname) = &ex('webtags', $FORM{"newname"}, 3);
  124.     $newname = &remove_links($newname);
  125.     &error_message("Rename Error", "You didn't specify a new subtopic/link name!") if $newname eq "";
  126.     &error_message("Formatting Error", "The following formatting error was returned:<BR><BR>$newname<BR><BR>") if $newname =~ /<H3>FORMATTING/i;
  127.     if ($FORM{'action'} eq "rename_a_subtopic") {
  128.         $subtopic = $FORM{'subtopic'};
  129.         $subtopic =~ s/\D//g;
  130.         &error_message("Rename Error", "You didn't specify a valid initial subtopic!") if $subtopic == 0;
  131.         &ex("rename_subtopic", $FORM{"HTTP_REFERER"}, $subtopic, $newname);
  132.     } else {
  133.         $linknum = $FORM{'link'};
  134.         $url = &remove_html($FORM{'url'});
  135.         if ($FORM{'frame'} eq "top") {
  136.             $target = "_parent";
  137.         } elsif ($FORM{'frame'} eq "new") {
  138.             $target = "_blank";
  139.         } else {
  140.             $target = "Main";
  141.         }
  142.         &ex("rename_link", $FORM{"HTTP_REFERER"}, $linknum, $newname, $url, $target);
  143.     }
  144.     &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  145. }
  146. if ($FORM{'action'} eq "move_subtopic") {
  147.     &check_passwd;
  148.     &extract ($FORM{'HTTP_REFERER'});
  149.     &verify_owner ($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permissions to move subtopics from this page!");
  150.     $oldtopic = $topic_number;
  151.     $oldparent = $me_number;
  152.     &extract("//$FORM{'click'}.$ext");
  153.     &verify_owner ($owner,$FORM{'username'}) || &error_message("Permissions Error", "You do not have permissions to move subtopics to this page!");
  154.     $newtopic = $topic_number;
  155.     $newtopic_hold = $newtopic;
  156.     $newhome = $me_number;
  157.     $newhome_hold = $newhome;
  158.     @tomove = split(/,/, $FORM{'move'});
  159.     foreach $page (@tomove) {
  160.         $page =~ s/^0//;
  161.     }
  162.     $tomove = join(",", @tomove);
  163.     &ex('move_page', $oldtopic, $tomove, $oldparent, $newtopic, $newhome);
  164.     &extract("//$newtopic_hold/$newhome_hold.$ext");
  165.     if ($param !~ /Sublist/) {
  166.         &ex('change_layout', $newtopic_hold, $newhome_hold, $param . "Sublist");
  167.     }
  168.     ($dt) = &ex('get_date_time', "short");
  169.     ($ts) = &ex('get_date_time', "long");
  170.     $ts =~ s/\W//g;
  171.     &ex('update_time', $topic_number, $me_number, $parent_number, $ts, $dt);
  172.     &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});    exit(0);
  173. }
  174. if ($FORM{'action'} eq "messages") {
  175.     &check_passwd;
  176.     &extract($FORM{'HTTP_REFERER'});
  177.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit this topic!");
  178.     if ($FORM{'SELECTION'} =~ /delete(\w+)/) {
  179.         $todo = $1;
  180.         if ($todo ne "all") {
  181.             $todo =~ s/\D//g;
  182.             if ($todo != 0) {
  183.                 &ex('remove_message', $FORM{"HTTP_REFERER"}, $todo);
  184.             }
  185.         } else {
  186.             &ex('remove_message', $FORM{"HTTP_REFERER"}, $FORM{'MARK'});
  187.         }
  188.         &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  189.     } elsif ($FORM{'SELECTION'} =~ /move(\w+)/) {
  190.         $tomove = $1;
  191.         &ex('move_message_form', $topic_number, $tomove, $FORM{"move"}, $FORM{"MARK"}, $FORM{"HTTP_REFERER"}, $FORM{"username"});
  192.         exit(0);
  193.     } elsif ($FORM{'SELECTION'} =~ /edit(\d+)/) {
  194.         $toedit = $1;
  195.         &ex('edit_message_form', $topic_number, $me_number, $toedit, "", "", $FORM{"username"});
  196.         exit(0);
  197.     } elsif ($FORM{'SELECTION'} =~ /reorder/) {
  198.         undef @data;
  199.         undef @datakeys;
  200.         foreach $key (keys(%FORM)) {
  201.             $key2 = $key;
  202.             $keystr .= "$key2=$FORM{$key2}<BR>";
  203.             if ($key2 =~ /^ORDER/) {
  204.                 $key2 =~ s/^ORDER//g;
  205.                 push (@data, $key2);
  206.                 push (@dataval, $FORM{$key});
  207.             }
  208.         }
  209.         @array = @data[sort {$dataval[$a] <=> $dataval[$b]} $[..$#data];
  210.         $arraystr = join(":", @array);
  211.         &ex('reorder_messages', $FORM{"HTTP_REFERER"}, $arraystr);
  212.         &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  213.     }
  214. }
  215. if ($FORM{'action'} eq "edit_message") {
  216.     &check_passwd;
  217.     &extract($FORM{'HTTP_REFERER'});
  218.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit messages in this topic!");
  219.     $source = $FORM{"message"};
  220.     ($lint, $message) = &ex('webtags', $source, 0, 1);
  221.     &error_message ("Edit Message Error", "You cannot specify a blank message!") if $message eq "";
  222.     $FORM{'submit'} = "Preview" if $lint eq "!Error";
  223.     $error_force = 1 if $lint eq "!Error";
  224.     if ($pro) {
  225.         ($removed, $added) = &ex('compare_source', $source, $topic_number, $me_number, $FORM{'postindex'});
  226.         if ($added) {
  227.             $FORM{'submit'} = "Preview";
  228.             $message = "<H3>Editing Error</H3>The following references to images or attachments have been modified:<P><UL>";
  229.             @added = split(/\n/, $added);
  230.             foreach $line (@added) {
  231.                 $message .= "<LI>$line\n";
  232.             }
  233.             $message .= "</UL><P>Repair or remove these references, or cancel your editing.";
  234.         }
  235.     }    
  236.     if ($FORM{'submit'} =~ /Preview/) {
  237.         &ex('edit_message_form', $topic_number, $me_number, $FORM{"postindex"}, $source, $message, $FORM{"username"}, $error_force);
  238.         exit(0);
  239.     }
  240.     &ex('save_edited_message', $topic_number, $me_number, $FORM{"postindex"}, &escape($source), $message, $FORM{"username"});
  241.     &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  242. }
  243. if ($FORM{'action'} eq "move_message") {
  244.     &check_passwd;
  245.     &extract($FORM{'HTTP_REFERER'});
  246.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to move messages from this topic!");
  247.     ($old_topic,$old_page) = ($topic_number, $me_number);
  248.     if ($FORM{'click'}) {
  249.         &extract ("//$FORM{'click'}.$ext");
  250.         &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to move messages to this topic!");
  251.         ($new_topic, $new_page) = ($topic_number, $me_number);
  252.         $page_num = $new_page;
  253.     } else {
  254.         $new_topic = "Create";
  255.         $new_page = $FORM{'newname'};
  256.     }
  257.     ($new_page, $new_topic) = &ex('move_message', $old_topic, $old_page, $FORM{"move"}, $new_topic, $new_page, $FORM{"parm"});
  258.     if ($new_page != 0) {
  259.         $page_num = $new_page;
  260.         $new_topic = $old_topic if $new_topic =~ /\D/;
  261.         &extract ("//$new_topic/$new_page.$ext");
  262.         $param =~ s/noneset//g;
  263.         if ($param !~ /Messages/) {
  264.             &ex('change_layout', $new_topic, $page_num, $param . "Messages");
  265.             $param .= "Messages";
  266.             if ($param !~ /Add/ && $FORM{"parm"} == 1) {
  267.                 &ex('change_layout', $new_topic, $page_num, $param . "Add");
  268.             }
  269.         }
  270.     }
  271.     &extract("//$new_topic/$new_page.$ext");
  272.     ($dt) = &ex('get_date_time', "short");
  273.     ($ts) = &ex('get_date_time', "long");
  274.     $ts =~ s/\W//g;
  275.     &ex('update_time', $topic_number, $me_number, $parent_number, $ts, $dt);
  276.     &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  277. }
  278. if ($FORM{'action'} eq 'about_message') {
  279.     &check_passwd;
  280.     &extract ($FORM{'HTTP_REFERER'});
  281.     &verify_owner ($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit this page!");
  282.     $FORM{'message'} =~ s/^\s+//; $FORM{'message'} =~ s/\s+$//;
  283.     ($lint_subj, $new_message) = &ex('webtags', $FORM{'message'}, 1, 1);
  284.     $FORM{'submit'} = "Preview" if $lint_subj eq "!Error";
  285.     if ($FORM{'submit'} =~ /Preview/) {
  286.         $FORM{'message'} =~ s/&/&/g;
  287.         $FORM{'message'} =~ s/</</g;
  288.         $FORM{'message'} =~ s/>/>/g;
  289.         $FORM{'message'} =~ s/"/"/g;
  290.         &ex('preview_admin_message', $FORM{"message"}, $new_message, $FORM{"username"}, $FORM{"HTTP_REFERER"}, "about_message", "About Message");
  291.         exit(0);
  292.     } else {
  293.         $file = "$message_dir/$topic_number/$me_number.$ext";
  294.         &ex('change_about_message', $file, $FORM{"message"}, $new_message);
  295.         ($dt) = &ex('get_date_time', "short");
  296.         ($ts) = &ex('get_date_time', "long"); $ts =~ s/\W//g;
  297.         &ex('update_time', $topic_number, $me_number, $parent_number, $ts, $dt);
  298.         &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  299.     }
  300. }
  301. if ($FORM{'action'} eq 'announce_message') {
  302.     &check_passwd;
  303.     &extract ($FORM{'HTTP_REFERER'});
  304.     &verify_owner ($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit this page!");
  305.     $FORM{'message'} =~ s/^\s+//; $FORM{'message'} =~ s/\s+$//;
  306.     ($lint_subj, $new_message) = &ex('webtags', $FORM{'message'}, 1, 1);
  307.     $FORM{'submit'} = "Preview" if $lint_subj eq "!Error";
  308.     if ($FORM{'submit'} =~ /Preview/) {
  309.         $FORM{'message'} =~ s/&/&/g;
  310.         $FORM{'message'} =~ s/</</g;
  311.         $FORM{'message'} =~ s/>/>/g;
  312.         $FORM{'message'} =~ s/"/"/g;
  313.         &ex('preview_admin_message', $FORM{"message"}, $new_message, $FORM{"username"}, $FORM{"HTTP_REFERER"}, "announce_message", "Announcement");
  314.         exit(0);
  315.     } else {
  316.         $file = "$message_dir/$topic_number/$me_number.$ext";
  317.         &ex('change_announce_message', $file, $FORM{"message"}, $new_message);
  318.         ($dt) = &ex('get_date_time', "short");
  319.         ($ts) = &ex('get_date_time', "long"); $ts =~ s/\W//g;
  320.         &ex('update_time', $topic_number, $me_number, $parent_number, $ts, $dt);
  321.         &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  322.     }
  323. }
  324. if ($FORM{'action'} eq "change_layout") {
  325.     &check_passwd;
  326.     &extract ($FORM{'HTTP_REFERER'});
  327.     &verify_owner($owner, $FORM{'username'}) || &error_message("Permissions Error", "You do not have permission to edit this page!");
  328.     $layout = "";
  329.     $layout .= "Sublist" if $FORM{'element1'} eq "on";
  330.     $layout .= "Create" if $FORM{'element2'} eq "on";
  331.     $layout .= "About" if $FORM{'element3'} eq "on";
  332.     $layout .= "Messages" if $FORM{'element4'} eq "on";
  333.     $layout .= "Add" if $FORM{'element5'} eq "on";
  334.     $layout .= "Announcement" if $FORM{'element6'} eq "on";
  335.     $layout .= "Archive" if $param =~ m|Archive|;
  336.     &ex('change_layout', $topic_number, $me_number, $layout);
  337.     $append = "?username=$FORM{'username'}";
  338.     &ex("page_mgr_2", $FORM{"HTTP_REFERER"},$FORM{"username"});
  339.     exit(0);
  340. }
  341. &error_message("Invalid Query", "The form action $FORM{action} is not valid for this script");
  342.