home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / discus_admin_1357211388 / source / admin-pl.pl < prev    next >
Text File  |  2009-11-06  |  7KB  |  245 lines

  1. # FILE: admin-pl.pl
  2. # DESCRIPTION: Administration function control
  3. #-------------------------------------------------------------------------------
  4. # DISCUS COPYRIGHT NOTICE
  5. #
  6. # Discus is copyright (c) 2002 by DiscusWare, LLC, all rights reserved.
  7. # The use of Discus is governed by the Discus License Agreement which is
  8. # available from the Discus WWW site at:
  9. #    http://www.discusware.com/discus/license
  10. #
  11. # Pursuant to the Discus License Agreement, this copyright notice may not be
  12. # removed or altered in any way.
  13. #-------------------------------------------------------------------------------
  14.  
  15. use strict;
  16. use vars qw($GLOBAL_OPTIONS $DCONF $PARAMS);
  17.  
  18. ###
  19. ### admin_control
  20. ###
  21. ### Delegates responsibility for all requests coming in to administration
  22. ### program.
  23. ###
  24.  
  25. sub admin_control {
  26.     dreq("authpass", "template");
  27.     my $FORMref = {};
  28.     if ($ENV{'CONTENT_TYPE'} =~ m|multipart|) {
  29.         dreq("fcn-mtp");
  30.         $FORMref = parse_multipart($ENV{'CONTENT_LENGTH'});
  31.     } else {
  32.         $FORMref = parse_form($ENV{'QUERY_STRING'}, $ENV{'CONTENT_LENGTH'});
  33.     }
  34.     if ($GLOBAL_OPTIONS->{'admin_actionlog'} == 1 && $FORMref->{username} ne "") {
  35.         admin_action_log($FORMref);
  36.     }
  37.     if ($FORMref->{'action'} eq "" || $FORMref->{'action'} eq "qmenu" || $FORMref->{'action'} eq "menu" || $FORMref->{'action'} eq "first_pass" || $FORMref->{'action'} eq "firstpass") {
  38.         dreq("adm-menu");
  39.         MENU_admin($FORMref);
  40.     }
  41.     if ($FORMref->{action} =~ m|^upgrade|) {
  42.         dreq("upgr31");
  43.         upgrade_version_310($FORMref, undef);
  44.     }
  45.     if ($FORMref->{'action'} =~ m|^acc|) {
  46.         dreq("adm-accs");
  47.         ACCESS_admin($FORMref);
  48.     }
  49.     if ($FORMref->{'action'} =~ m|^arch|) {
  50.         dreq("adm-arch-PRO");
  51.         ARCHIVE_admin($FORMref);
  52.     }
  53.     if ($FORMref->{'action'} =~ m|^user| || $FORMref->{action} =~ m|^um-|) {
  54.         header();
  55.         dreq("adm-user");
  56.         USER_admin($FORMref);
  57.     }
  58.     if ($FORMref->{'action'} =~ m|^pm-|) {
  59.         dreq("adm-page");
  60.         PAGE_admin($FORMref);
  61.     }
  62.     if ($FORMref->{'action'} =~ m|^mod_|) {
  63.         dreq("adm-mod");
  64.         MODERATOR_admin($FORMref);
  65.     }
  66.     if ($FORMref->{'action'} =~ m|^grp_|) {
  67.         dreq("adm-grp");
  68.         GROUP_admin($FORMref);
  69.     }
  70.     if ($FORMref->{'action'} =~ m|^database|) {
  71.         dreq("adm-db");
  72.         DATABASE_admin($FORMref);
  73.     }
  74.     if ($FORMref->{'action'} =~ m%^(version|first|quota|logout|color|taskman)%) {
  75.         dreq("adm-misc");
  76.         MISC_admin($FORMref);
  77.     }
  78.     if ($FORMref->{'action'} =~ m%^topic%) {
  79.         dreq("adm-tpc");
  80.         TOPIC_admin($FORMref);
  81.     }
  82.     if ($FORMref->{'action'} =~ m%^appear%) {
  83.         dreq("adm-appr");
  84.         APPEAR_admin($FORMref);
  85.     }
  86.     if ($FORMref->{'action'} =~ m%^data_% || $FORMref->{'action'} =~ m%^dr_%) {
  87.         dreq("adm-dr");
  88.         DR_admin($FORMref);
  89.     }
  90.     if ($FORMref->{'action'} =~ m%^log_%) {
  91.         dreq("loganaly-PRO");
  92.         log_analysis_handler($FORMref);
  93.     }
  94.     if ($FORMref->{'action'} =~ m%^options%) {
  95.         dreq("adm-opts");
  96.         OPTS_admin($FORMref);
  97.     }
  98.     if ($FORMref->{'action'} =~ m%^queue%) {
  99.         dreq("queue2-PRO");
  100.         QUEUE_admin($FORMref);
  101.     }
  102.     if ($FORMref->{'action'} =~ m|^update_|) {
  103.         dreq("adm-upd");
  104.         UPDATE_admin($FORMref);
  105.     }
  106.     if ($FORMref->{'action'} =~ m|^schedule_|) {
  107.         dreq("schedule-PRO");
  108.         schedule_mgr_admin_interface($FORMref);
  109.     }
  110.     if ($FORMref->{'action'} =~ m|^back|) {
  111.         dreq("adm-bkup-PRO");
  112.         BACKUP_admin($FORMref);
  113.     }
  114.     if ($FORMref->{'action'} =~ m|^regen(\d+)$|) {
  115.         dreq("fcn-regn");
  116.         REGEN_admin($FORMref);
  117.     }
  118.     if ($FORMref->{action} =~ m|^debug|) {
  119.         dreq("prgdebug");
  120.         program_debug_admin_interface($FORMref);
  121.     }
  122.     if ($FORMref->{action} =~ m|^selfreg|) {
  123.         dreq("selfreg-PRO");
  124.         selfreg_administration($FORMref);
  125.     }
  126.     if ($FORMref->{action} =~ m|^email_admin|) {
  127.         dreq("em-admin-PRO");
  128.         email_admin_administration($FORMref);
  129.     }
  130.     if ($FORMref->{action} eq 'quick') {
  131.         dreq("quickadm-PRO");
  132.         quick_admin_handler($FORMref);
  133.     }
  134.     fatal_error($FORMref);
  135. }
  136.  
  137. ###
  138. ### admin_action_log
  139. ###
  140. ### Keeps a log of everything that everyone did to your administration program
  141. ### if you've turned this on in Options Manager.
  142. ###
  143.  
  144. sub admin_action_log {
  145.     my ($FORMref) = @_;
  146.     if (open(LOG, ">>$DCONF->{admin_dir}/msg_index/admin-actionlog.txt")) {
  147.         print LOG "$FORMref->{'username'}\t$ENV{'REMOTE_ADDR'}\t", time, "\t";
  148.         if ($0 =~ m|([\w\-]+)\.$DCONF->{cgi_extension}|) {
  149.             print LOG $1, "\t";
  150.         } else {
  151.             print LOG "?\t";
  152.         }
  153.         foreach my $key (keys(%{$FORMref})) {
  154.             next if $key eq "COOKIE";
  155.             print LOG escape($key), "=";
  156.             if ($key =~ m|^pass|) {
  157.                 print LOG escape("*") if $FORMref->{$key} ne "";
  158.                 print LOG "BLANK" if $FORMref->{$key} eq "";
  159.             } else {
  160.                 print LOG escape($FORMref->{$key});
  161.             }
  162.             print LOG ",";
  163.         }
  164.         print LOG "\n";
  165.         close (LOG);
  166.     } else {
  167.         log_error("src-board-subs-admin", "log_admin_action", "Could not append action log file: $!");
  168.     }
  169. }
  170.  
  171. ###
  172. ### fatal_error
  173. ###
  174. ### Hopefully this will never be seen.  It happens if there is a serious program
  175. ### error (mainly if the program falls through the admin_control routine, with a
  176. ### malfunctioning function handler).
  177. ###
  178.  
  179. sub fatal_error {
  180.     my ($FORMref) = @_;
  181.     header();
  182.     my $is_pro = "";
  183.     $is_pro = "PRO" if $DCONF->{pro};
  184.     print <<End_Error_Message;
  185. <html><head><title>Internal Program Error</title>
  186. <style>
  187. body { font-family: arial,helvetica }
  188. pre { font-family: courier new; font-size: 11pt; }
  189. </style>
  190. </head>
  191. <body bgcolor=#ffffff text=#000000 link=#0000ff>
  192. <font size=4 color=#ff0000><b>Internal Program Error</b></font><hr>
  193. This error was generated by the Discus program after receiving invalid input or
  194. experiencing an execution error.  If you experienced this error when performing
  195. a normal operation within the Discus program, first check the
  196. <a href=diagnose.$DCONF->{cgi_extension} target=_blank>program diagnostics</a>.
  197. If that does not reveal any error conditions, please contact DiscusWare with the
  198. following information, along with a description of what you were doing when you
  199. received this error message.
  200. <p><pre>
  201. <b>URL to board:</b>   $DCONF->{html_url}
  202. <b>Discus version:</b> $PARAMS->{release}.$PARAMS->{revision} $is_pro
  203. <b>Program running:</b> $0
  204. End_Error_Message
  205.     foreach my $key (keys(%{$FORMref})) {
  206.         print "<FONT COLOR=#0000ff>$key</FONT>=<FONT COLOR=#ff0000><B>$FORMref->{$key}</B></FONT>\n";
  207.     }
  208.     print "</pre></body></html>\n";
  209.     program_exit(0);
  210. }
  211.  
  212. ###
  213. ### bad_login
  214. ###
  215. ### Complaint if someone shouldn't be here
  216. ###
  217.  
  218. sub bad_login {
  219.     my ($arg) = @_;
  220.     my $subst = {};
  221.     $subst->{general}->{reason} = 0 if $arg->{bad_menu_username};
  222.     $subst->{general}->{reason} = 1 if $arg->{username} || $arg->{bad_username};
  223.     $subst->{general}->{reason} = 2 if $arg->{bad_database};
  224.     $subst->{general}->{reason} = 3 if $arg->{bad_backup};
  225.     $subst->{general}->{reason} = 4 if $arg->{superuser} || $arg->{superuser_required};
  226.     $subst->{general}->{reason} = 5 if $arg->{privilege};
  227.     $subst->{general}->{reason} = 6 if $arg->{group_privilege};
  228.     screen_out("badlogin", $subst);
  229. }
  230.  
  231. ###
  232. ### admin_error
  233. ###
  234. ### Miscellaneous Error Messages
  235. ###
  236.  
  237. sub admin_error {
  238.     my ($code) = @_;
  239.     undef my $subst;
  240.     $subst->{c}->{e} = $code;
  241.     screen_out("admerror", $subst);
  242. }
  243.  
  244. 1;
  245.