#!/usr/bin/perl
# copyright2003 George Bacon, San Diego CA. GeorgeX@gmail.com
use CGI;
use CGI::Cookie;
use DBI;
use LWP::Simple qw($ua get);
use MIME::Entity;
use Data::Dumper;
#use LWP::Simple qw(!head);
use strict;
#-------------------------------------------------
our $mailprog;
our $title;
our $maxPin;
our $SCH;
our $DPIN;
our $PNnum;
our $DP;
our $MP; # Master Password
our $webmaster;
our $bgc;
our $trc1;
our $trb1;
our $trc2;
our $trb2;
our $trsz;
our $sbb;
our $sbg;
our $qqq;
our $database;
our $dbuser;
our $dbpass;
our $debug;
our $addressMsg;
our $footer;
#-------------------------------------------------
#my $host = $ENV{HTTP_HOST};
require "./config.cgi";
$CGI::POST_MAX = 1024 * 100000;
my $cgi = new CGI;
my $args = $cgi->Vars;
#print "Content-type: text/html\n\n";
# TEMP
#foreach my $k (keys %$args) {
# print "$k = $$args{$k}
\n";
#}
#exit;
if ($$args{debug} =~ /[Y1]/i) {
$debug = 'Y';
}
my %status = ('A' => 'Active',
'a' => 'Address List',
'B' => 'Alumni Status',
'b' => 'Social Alumnus',
'C' => 'updateCalendar',
'D' => 'aDdpledges',
'E' => 'Commander',
'e' => 'Email List',
'F' => 'Fundraising',
'G' => 'Chaplain',
'H' => 'House Corp',
'h' => 'Advisory Board',
'I' => 'Initiatepledges',
'i' => 'IFC Rep',
'J' => 'Holdover',
'L' => 'Lt. Commander',
'l' => 'LEAD',
'c' => 'Public Relations',
'M' => 'House Manager',
'N' => 'Historian',
'g' => 'SnakeBite Toggle',
'O' => 'Recorder',
'P' => 'Pledge Marshal',
'p' => 'AccessPhoneList',
'Q' => 'Sentinel',
'R' => 'Rush Chair',
'r' => 'Risk Reduction',
'S' => 'Social Chair',
's' => 'Sports Chair',
'T' => 'Treasurer',
't' => 'Sorority Softball',
'U' => 'statUschanges',
'W' => 'Webmaster',
'w' => 'White Rose',
'X' => 'aXcesscontrol',
'x' => 'Expelled',
'Y' => 'Philanthropy',
'y' => 'Scholarship',
'Z' => 'Alumni Contact');
my @ustatus = ('A','B','b','E','F','G','i','L','M','N','O','P','Q','R','r','S','s','T','t','w','Y','y','Z','c','l','x'); # 'x' last
my %officers = ('E' => 'Commander',
'F' => 'Fundraising',
'G' => 'Chaplain',
'i' => 'IFC Rep',
'c' => 'Public Relations',
'L' => 'Lt. Commander',
'l' => 'LEAD',
'M' => 'House Manager',
'N' => 'Historian',
'O' => 'Recorder',
'P' => 'Pledge Marshal',
'Q' => 'Sentinel',
'R' => 'Rush Chair',
'S' => 'Social Chair',
's' => 'Sports Chair',
'T' => 'Treasurer',
't' => 'Sorority Softball',
'w' => 'White Rose',
'Y' => 'Philanthropy',
'y' => 'Scholarship',
'Z' => 'Alumni Contact',
'r' => 'Risk Reduction');
my $officers;
foreach my $okey (keys %officers) {
$officers .= $okey;
}
my @mChecked;
my @months = qw(MON Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
$$args{pin} =~ s/\D//g unless ($$args{pin} =~ /^(master|webmaster|pledge|-1869)$/i);
if ($$args{pin} =~ /^0+$/ || $$args{pin} =~ /(pledge|none)/i ) {
$$args{pin} = -1869;
}
my $action = $$args{action};
my $dbh;
if ($action) {
$dbh = &dbConnect($args);
}
if (!$action) {
&initialize($args);
&signInForm($args);
&eXit($args);
} elsif ($action =~ /enter/i) {
&login($dbh,$args);
} else {
my $mHref;
if (! ($$args{pin} =~ /^(master|webmaster)$/i && $$args{youknow} =~ /$MP/i) ) {
if ($$args{pin} > 0) {
$mHref = $dbh->selectrow_hashref('select * from members where pin = ?',{},$$args{pin});
} else {
$mHref = $dbh->selectrow_hashref('select * from members where pin = ? && password1 = ?',
{},$$args{pin},$$args{youknow});
}
%$args = (%$args, %$mHref);
}
#TEMP
#print "Content-type: text/html\n\n";
#foreach my $k (keys %$args) {
# print "$k = $$args{$k}
\n";
#}
#exit;
if ($action =~ /i\s*forgot/i) {
&emailPassword($dbh,$args);
} else {
if ($action !~ /^exit$/i) {
&lookUp($dbh,$args);
}
if ($action =~ /points/i) {
&viewPoints($cgi);
exit;
}
&initialize($args);
if ($action =~ /main menu/i) { &menuForm($dbh,$args); } elsif
($action =~ /update.*info/i) { &updateForm($dbh,$args); } elsif
($action =~ /update$/i) { &updateRec($dbh,$args); } elsif
($action =~ /bro.*network/i) { &broNetwork($dbh,$args); } elsif
($action =~ /phone.*list/i) { &phoneList($dbh,$args); } elsif
($action =~ /pledge setup/i) { &pledgeForm($dbh,$args); } elsif
($action =~ /add pledge/i) { &addPledge($dbh,$args); } elsif
($action =~ /remove pledge/i) { &deletePledges($dbh,$args); } elsif
($action =~ /make holdover/i) { &makeHoldover($dbh,$args); } elsif
($action =~ /snake\s*mail/i) { &snakeMailForm($dbh,$args); } elsif
($action =~ /snake\s*bite/i) { &snakeBiteForm($dbh,$args); } elsif
($action =~ /send it/i) { &sendSnakeMail($dbh,$args,$cgi); } elsif
($action =~ /text it/i) { &sendSnakeBite($dbh,$args); } elsif
($action =~ /announcements/i) { &displayPosts($dbh,$args); } elsif
($action =~ /announcement/i) { &postForm($dbh,$args); } elsif
($action =~ /remove post/i) { &removePost($dbh,$args); } elsif
($action =~ /guest|event/i) { &guestLists($dbh,$args); } elsif
($action =~ /post/i) { &updatePost($dbh,$args); } elsif
($action =~ /calendar/i) { &calendarMenu($dbh,$args); } elsif
($action =~ /points/i) { &viewPoints($cgi); } elsif
($action =~ /initiate pledges/i) { &makeActiveForm($dbh,$args); } elsif
($action =~ /access.*control/i) { &accessForm($dbh,$args); } elsif
($action =~ /update.*access/i) { &updateAccess($dbh,$args); } elsif
($action =~ /status.*updates/i) { &statusForm($dbh,$args); } elsif
($action =~ /update.*status/i) { &updateStatus($dbh,$args); } elsif
($action =~ /master.*list/i) { &masterList($dbh,$args); } elsif
($action =~ /purge.*emails/i) { &purgeEmails($dbh,$args); } elsif
($action =~ /donations/i) { &donations($dbh,$args); } elsif
($action =~ /pay pal/i) { &paypal($dbh,$args); } elsif
($action =~ /initiate/i) { &makeActive($dbh,$args); } else {
if ($debug =~ /[Y1]/i) {
# debug
} else {
print "";
}
}
}
}
&eXit($args);
sub eXit {
my ($args) = @_;
print '