#!/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 ''; exit; } sub initialize { my ($args,$loginError,$newLogin) = @_; my $rows; if ($$args{pin} =~ /(($DP)?\s?\d{1,5})|pledge/i) { my $storepin = $$args{pin}; if ($$args{pin} == -1869) { $storepin = 'pledge'; } my $pinCookie = new CGI::Cookie(-name=>"${DP}pin", -value=>"$storepin", -path=>"/", -domain=>".sigmanusdsu.com", -expires=>"+12M"); if ($debug =~ /[Y1]/i) { $$args{show} .= "
SET COOKIE: ${DP}pin = $$args{pin}
"; $$args{show} .= "Set-Cookie: $pinCookie
\n"; } print "Set-Cookie: $pinCookie\n"; if ($newLogin) { my $loginCookie = new CGI::Cookie(-name=>'firstloginx', -value=>"$$args{pin}", -path=>"/", -domain=>".sigmanusdsu.com", -expires=>"+12M"); print "Set-Cookie: $loginCookie\n"; $rows = $dbh->do("insert into plog (pin,action,tstamp, what, ip,host) values ($$args{pin},'FIRSTLOGIN',NULL,'Previous: $newLogin', '$ENV{REMOTE_ADDR}','$ENV{REMOTE_HOST}')"); } } print "Content-type: text/html\n\n"; #print $$args{cgi}->start_html(-title=>$title, # bgcolor=>$bgc, # text=>'gold', # link=>'blue', # vlink=>'blue'); print < $title EOH if ($action =~ /snake|send/i) { &attachmentsJavascript; } my $snakeBiteLoad; if ($action =~ /bite|text/i) { $snakeBiteLoad = 'onLoad=checkCount();' } print "\n"; if ($debug =~ /[Y1]/i) { &showVars($dbh,$args); } } sub broNetwork { my ($dbh,$args) = @_; my $sColor; my $priv = $$args{priv}; my $stmt = "select pin, status, first, last, nickname, occupation, hometown, email, bday, message, link, linkname, password1, password2, password3, priv from members where reg = 'Y' and status != 'E' order by status, pin desc"; my $sth = $dbh->prepare($stmt); $sth->execute || die "execute failed $stmt\n"; print ""; print "\n"; print ""; my $prv; my ($tr); while (my ($bpin, $stat, $first, $last, $nickname, $occupation, $hometown, $email, $bday, $message, $link, $namelink, $password1,$password2,$password3,$prv) = $sth->fetchrow_array ) { if ($tr eq 'tr2') { $tr = 'tr1'; } else { $tr = 'tr2'; } $bday = $months[substr($bday,0,2)] . substr($bday,2,2); my $name = "$first $last"; my $dPin = $bpin; if ($$args{pin} < 0) { $dPin = $qqq; } if ($stat =~ /X/i) { $stat = 'Alum'; $sColor = 'blue'; } elsif ($stat =~ /[AJ]/i) { my $s; if ($prv) { #($s) = $prv =~ /^([^CDIUHX])/; ($s) = $prv =~ /^([$officers])/; } $stat = $officers{$s} || 'Active'; $sColor = 'red'; } else { $stat = 'Pledge'; $sColor = 'green'; } print ""; if ($email =~ /\@/) { print ""; } else { print ""; } print ""; print ""; if (!$nickname || $nickname eq ' ') { print ""; } else { $nickname =~ s/"//g; if ($nickname =~ /^[^,]+,[^,]+$/) { my ($uno, $dos) = split(/,/,$nickname); $dos =~ s/^ //; $nickname = "\"$uno\"
\"$dos\""; } else { if ($nickname =~ /^[^,]+\/[^,]+$/) { my ($uno, $dos) = split(/\//,$nickname); $uno =~ s/\s+$//; $dos =~ s/^\s+//; $nickname = "\"$uno\"
\"$dos\""; } else { $nickname = "\"$nickname\""; } } print ""; } $occupation = ($occupation =~ /\w/) ? $occupation : ' '; print ""; my $fullLink; if ($link) { if ($namelink =~ /\w/) { $fullLink = "$namelink"; } else { $fullLink = "$link"; } } else { $fullLink = ' ' } if ($message && $message ne ' ') { print ""; } else { print ""; } print ""; } print "
$DP Name NickName HomeTown Major/Occupation BDAY Message
$email
  $dPin $stat$name $nickname$hometown $occupation
$bday
$message $fullLink$fullLink
"; print "
"; print "
"; print "
"; &printLoginData($args); &footers; print "
"; } sub masterList { my ($dbh,$args) = @_; my $sColor; my $stmt = "select pin, status, snakemail, first, last, priv, password1, password2, password3, email from members order by pin desc, status"; my $sth = $dbh->prepare($stmt); $sth->execute || die "execute failed $stmt\n"; print ""; print "
\n"; print ""; my $prv; my ($tr); while (my ($mpin, $stat, $snakemail, $first, $last, $prv, $password1, $password2,$password3,$email) = $sth->fetchrow_array ) { if ($tr eq 'tr2') { $tr = 'tr1'; } else { $tr = 'tr2'; } my $name = "$first $last"; my $dPin = $mpin; if ($$args{pin} < 0) { $dPin = '?'; } if ($stat =~ /X/i) { $stat = 'Alum'; $sColor = 'blue'; } elsif ($stat =~ /[A]/i) { my $s; if ($prv) { ($s) = $prv =~ /^([A-Z])/i; } $stat = $status{$s} || 'Active'; $sColor = 'red'; } elsif ($stat eq 'J') { $stat = 'Holdover'; $sColor = 'purple'; } elsif ($stat eq 'P') { $stat = 'Pledge'; $sColor = 'green'; } elsif ($stat eq 'E') { $stat = 'Expelled'; $sColor = 'gray'; } print ""; print ""; } print "
Privs $DP Status Name Password1 Password2 Password3 Snakemail Email
$prv $dPin $stat $name $password1 $password2 $password3 $snakemail $email
"; print "
"; print "
"; print "
"; &printLoginData($args); &footers; print "
"; } sub donations { my ($dbh,$args) = @_; print <  
To all who have contributed: Thank You!!!
 

List Contribution Anonymously

House Improvement Fund
Scholarship/Rush Fund


-OR-
Donation can be mailed to:

  Montezuma Mesa Properties
  9270 Adolphia Street
  San Diego, CA  92126

  Contributions within last 1000 days:
EOH my $sColor; my $sthN = $dbh->prepare("select concat(first,' ',last) from members where pin = ?"); my $sthT = $dbh->prepare("select sum(payment_gross) from paypal_ipn where txn_id = ?"); my $sthLT = $dbh->prepare("select sum(amount) from donations where pin = ? and type = 'M'"); my $sthD = $dbh->prepare("select pin, upper(date_format(tstamp,'\%b\%Y')), first, last, payment_status, txn_id, type, anonymous, amount, what from donations where (type = 'L' or payment_status in ('Completed','Pending') or payment_status IS NULL) and ( (to_days(current_date) - to_days(tstamp)) < 1001 ) order by tstamp desc"); $sthD->execute; #print ""; print "

\n"; print ""; my $tr; my %hkseen; while ( my ($ppin, $tstamp, $first, $last, $payment_status, $txn_id, $type, $anonymous, $amount, $what) = $sthD->fetchrow_array) { if ($tr eq 'dr2') { $tr = 'dr1'; } else { $tr = 'dr2'; } if ($txn_id && $type eq 'M') { my ($netTotal) = $dbh->selectrow_array($sthT,{},$txn_id); if (!$netTotal) { #print "[$txn_id]
"; next; } } my $name; my $lifetime; if ($ppin) { ($lifetime) = $dbh->selectrow_array($sthLT,{},$ppin); if ($lifetime) { $lifetime = "\$$lifetime"; } else { $lifetime = ''; } } if ($anonymous eq 'Y') { $name = 'Anonymous'; $ppin =~ s/\d/\?/g; } elsif ($ppin) { ($name) = $dbh->selectrow_array($sthN,{},$ppin); } $name ||= "$first $last"; $ppin ||= ' '; if (!$what || $what eq 'General Fund') { $what = 'House Improvement Fund'; } $amount = "\$$amount"; if (length($amount) == 6) { $amount = "  $amount"; } my $donation = ($type eq 'M') ? "$what: $amount" : $what; my $dalign = 'right'; if ($type ne 'M') { $dalign = 'middle'; } if ($ppin && $hkseen{$ppin}) { $lifetime = ''; } else { $hkseen{$ppin} = 'Y'; } print "
"; print ""; } print "
Date HK Name Contribution Lifetime
$tstamp   $ppin $name   $donation   $lifetime
"; print ""; print "
"; print "
"; &printLoginData($args); print "

 "; &footers; print "

"; } sub paypal { my ($dbh,$args) = @_; my $name = "$$args{first} $$args{last}"; if ($$args{status} eq 'P') { $name = "P:$name"; } elsif ($$args{status} eq 'J') { $name = "H:$name"; } else { $name = "$$args{pin}:$name"; } print <
 

For: 

 

 

Link to give to Parents:   SigmaNuSDSU.com/paypal

EOH print "
"; &printLoginData($args); &footers; print "
"; } sub phoneList { my ($dbh,$args) = @_; my $sColor; my $stmt = "select pin, status, first, last, phone from members where phone > ' ' and status != 'E' and (status in ('A','J','P') or pin > ($$args{maxpin} - 125) or pin > ($$args{minpinA} - 20) or (status = 'X' and pin > 180 and (priv like '\%p%' or priv like '\%h%')) ) order by status, pin desc"; my $sth = $dbh->prepare($stmt); $sth->execute || die "execute failed $stmt\n"; print "

~PHONE LIST~

"; print ""; print "
\n"; print ""; my $prv; my ($tr); while (my ($ppin, $stat, $first, $last, $ph) = $sth->fetchrow_array ) { $ph =~ s/\D//g; $ph = substr($ph,0,10); $ph = '(' . substr($ph,0,3) . ') ' . substr($ph,3,3) . '-' . substr($ph,-4); if ($tr eq 'tr2') { $tr = 'tr1'; } else { $tr = 'tr2'; } my $name = "$first $last"; my $dPin = $ppin; if ($ppin < 0) { $dPin = $qqq; } if ($stat =~ /X/i) { $stat = 'Alum'; $sColor = 'blue'; } elsif ($stat =~ /[A]/i) { my $s; if ($prv) { ($s) = $prv =~ /^([$officers])/; } $stat = $officers{$s} || 'Active'; $sColor = 'red'; } elsif ($stat =~ /[J]/i) { $stat = 'Active'; $sColor = 'red'; } else { $stat = 'Pledge'; $sColor = 'green'; } print ""; print ""; } print "
$DP STATUS NAME PHONE NUMBER
$dPin $stat $name $ph
"; print "
"; print "
"; print "
"; &printLoginData($args); &footers; print "
"; } sub displayPosts { my ($dbh,$args) = @_; my ($pPin,$pFirst,$pLast,$pStatus,$header); my $stmt = "select P.pin, P.header, P.text, P.link, P.linkname, P.hcolor, P.tcolor, M.first, M.last, M.status, P.piclink from posts P left join members M on M.pin = P.pin where P.stopdate > date_add(sysdate(), INTERVAL -1 DAY) order by P.startdate desc"; my $sth = $dbh->prepare($stmt); $sth->execute || die "execute failed $stmt\n"; print '

'; my $postcount; while (my ($pPin, $header, $text, $plink, $linkname, $hcolor, $tcolor, $pFirst, $pLast, $pStatus, $piclink) = $sth->fetchrow_array ) { $postcount++; $text =~ s/\n\n/

/g; $text =~ s/\n\s*\n/

/g; $text =~ s/\n/
/g; print '

'; if ($tcolor =~ /purple/) { $tcolor = '#990099'; } elsif ($tcolor =~ /green/i) { $tcolor = '#00CC33'; } elsif ($tcolor =~ /cream/i) { $tcolor = 'beige'; } elsif ($tcolor =~ /sky/i) { $tcolor = 'skyblue'; } elsif ($tcolor =~ /blue/i) { $tcolor = 'steelblue'; } elsif ($tcolor =~ /aqua/i) { $tcolor = 'mediumaquamarine'; } elsif ($tcolor =~ /red/i ) { $tcolor = 'crimson'; } if ($hcolor =~ /purple/) { $hcolor = '#990099'; } elsif ($hcolor =~ /green/i) { $hcolor = '#00CC33'; } elsif ($hcolor =~ /cream/i) { $hcolor = 'beige'; } elsif ($hcolor =~ /sky/i) { $hcolor = 'skyblue'; } elsif ($tcolor =~ /blue/i) { $hcolor = 'steelblue'; } elsif ($hcolor =~ /aqua/i) { $hcolor = 'mediumaquamarine'; } elsif ($hcolor =~ /red/i ) { $hcolor = 'crimson'; } print "

$header

"; if ($piclink && $piclink ne ' ') { print "

\n"; } #print "
$text

"; print "
$text

"; if ($plink) { if ($linkname) { print "
$linkname
"; } else { print "
"; } } my $pname = "$pFirst $pLast"; $pname =~ s/\s+/ /; $pname = "- $DP" . "$pPin" . " $pname"; if ($pStatus =~ /X/i) { $pname .= ' (Alumnus) '; } if ($pPin eq '0') { $pname = '- WebMaster'; } print "

$pname

"; print '
'; print '
'; } $sth->finish; if (!$postcount) { print "

NO CURRENT POSTINGS

"; print '

'; } print '
'; print "
"; &printLoginData($args); &footers; print "
"; } sub login { my ($dbh,$args) = @_; my $password = $$args{youknow}; my $stmt; my $sth; if ($$args{pin} =~ /^(master|webmaster)$/i && $password =~ /$MP/i) { $$args{priv} = 'W'; $$args{PRIV} = 'W'; $$args{email} = $webmaster; $$args{EMAIL} = $webmaster; $$args{FIRST} = 'SigmaNu'; $$args{first} = 'SigmaNu'; $$args{LAST} = 'WebMaster'; $$args{last} = 'WebMaster'; &initialize($args); &menuForm($dbh,$args); &eXit($args); } if ($password =~ /^\s*$/ || $$args{pin} =~ /^\s*$/ || ($$args{pin} > $maxPin) || $$args{pin} !~ /^\-?\d+$/) { &loginError($dbh,$args); } if ($$args{pin} == -1869) { $stmt = "select * from members where status in ('P','J') and password1 = '$password' and pin < 1" } else { $stmt = "select * from members where pin = $$args{pin} and (password1 = '$password' or password2 = '$password' or password3 = '$password' or '$password' = '$MP' )" } $sth = $dbh->prepare($stmt) || die "error preparing $stmt\n"; $sth->execute || die "error executing $stmt\n"; my $mHash = $sth->fetchrow_hashref; if (!$mHash->{PIN} || $mHash->{STATUS} eq 'E') { &loginError($dbh,$args); } %$args = (%$args,%$mHash); if ($$args{pin} > 0) { my $sthX = $dbh->prepare("select block from blocklist where pin = $$args{pin}"); $sthX->execute; while ( my ($block) = $sthX->fetchrow_array ) { $$args{blocklist} .= "$block, "; } $$args{blocklist} =~ s/,\s+$//; } if ($$args{PRIV} !~ /W/i) { my $showPin = ($$args{pin} > 0) ? "$DP$$args{pin}" : 'Pledge'; if ($$args{STATUS} =~ /J/i) { $showPin = $qqq; } open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n"; print MAIL "From: $webmaster\n"; print MAIL "To: SigmaNuWebMaster\@gmail.com\n"; print MAIL "Subject: $showPin Login: $$args{FIRST} $$args{LAST} $ENV{REMOTE_ADDR} $ENV{REMOTE_HOST}\n\n"; print MAIL "\n"; close (MAIL); } my %cookies = CGI::Cookie->fetch; my $noLoginError = 0; my $newLogin; if (!$cookies{firstloginx}) { $newLogin = 'FIRST'; } else { $newLogin = $cookies{firstloginx}->value; if ($newLogin eq $$args{pin}) { $newLogin = 0; } } &initialize($args,$noLoginError,$newLogin); if ($$args{REG} !~ /Y/i) { &updateForm($dbh,$args); } else { my ($seconds_since) = $dbh->selectrow_array('select unix_timestamp(now()) - unix_timestamp(lastlogin) from members where pin = ? and first = ? and last = ?',{}, $$args{PIN}, $$args{FIRST}, $$args{LAST}); #print "SECONDS:[$seconds_since]\n"; if (!$seconds_since || $seconds_since > 250) { &sayName($$args{FIRST}, $$args{STATUS}); } &menuForm($dbh,$args); } $dbh->do("update members set lastlogin = now() where pin = ? and first = ? and last = ?",{},$$args{pin},$$args{first},$$args{last}); } sub lookUp { my ($dbh,$args) = @_; my $password = $$args{youknow}; my $stmt; my $sth; if ($$args{pin} =~ /^(master|webmaster)$/i && $password =~ /^$MP/i) { $$args{priv} = 'W'; $$args{PRIV} = 'W'; $$args{email} = $webmaster; $$args{EMAIL} = $webmaster; return; } if ($debug =~ /[Y1]/i) { $$args{show} .= "
USE PASSWORD: $password
"; } if (!$$args{pin} || !$password) { &initialize($args); &signInForm($args); &eXit($args); } if ($$args{pin} == -1869) { $stmt = "select * from members where status in ('P','J') and password1 = '$password' and pin < 1" } else { $stmt = "select * from members where pin = $$args{pin} and (password1 = '$password' or password2 = '$password' or password3 = '$password' or '$password' = '$MP' )" } $sth = $dbh->prepare($stmt) || die "error preparing $stmt\n"; $sth->execute || die "error executing $stmt\n"; my $mHash = $sth->fetchrow_hashref; if (!$mHash->{PIN}) { &loginError($dbh,$args); } if ($password =~ /^$MP$/i) { $password = $mHash->{PASSWORD1}; } #$$args{youknow} = $$args{PASSWORD1}; ??? $$args{youknow} = $$mHash{PASSWORD1}; %$args = (%$args, %$mHash); if ($$args{PIN} > 0) { my $sthX = $dbh->prepare("select block from blocklist where pin = $$args{pin}"); $sthX->execute; while ( my ($block) = $sthX->fetchrow_array ) { $$args{blocklist} .= "$block, "; } $$args{blocklist} =~ s/,\s+$//; } }; sub updateRec { my ($dbh,$args) = @_; my @errors; &mergeArgs($args); my $mcat = $$args{mcat}; my $snakemail = $$args{snakemail}; my $status = $$args{status}; $mcat =~ s/\W//g; if ($snakemail ne 'N') { if ($mcat) { $snakemail = $mcat; } else { $snakemail = 'Y'; } } if ($status =~ /[AJ]/) { $snakemail = 'Y'; } if (!$$args{email}) { push (@errors,"PLEASE ENTER EMAIL ADDRESS"); push (@errors,"(enter 'none' if you don't have an email address)"); } else { if ($$args{email} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { if ($$args{email} !~ /none/i) { push (@errors,"EMAIL ADDRESS IS INVALID"); } } } if (!$$args{first} || $$args{first} eq ' ' || !$$args{last} || $$args{last} eq ' ') { push (@errors,"FIRST AND LAST NAME ARE REQUIRED"); } if ($$args{youknow1} !~ /\w/) { push (@errors,"PASSWORD REQUIRED"); } else { if ($$args{pin} < 0 || $status =~ /P/i) { #my $initials = substr($first,0,1) . substr($last,0,1); #if (lc(substr($password1,0,2)) ne lc($initials)) { # push (@errors,"PLEDGE PASSWORD MUST START WITH FIRST AND LAST INTITIAL"); #} my ($cnt) = $dbh->selectrow_array('select count(*) from members where pin < 0 and password1 = ? and last != ?',{},$$args{youknow1},$$args{last}); if ($cnt) { push (@errors,"INVALID PASSWORD PLEASE CHOOSE ANOTHER"); } } } $$args{phone1} =~ s/\D//g; $$args{phone2} =~ s/\D//g; $$args{phone3} =~ s/\D//g; my ($phone,$celltype); $celltype = $$args{celltype}; if ($$args{phone1} || $$args{phone2} || $$args{phone3}) { $phone = $$args{phone} = "$$args{phone1}$$args{phone2}$$args{phone3}"; } if ($phone) { if ($phone !~ /^[1-9]\d{9}$/) { push (@errors,'PLEASE ENTER VALID PHONE NUMBER WITH AREA CODE'); } } else { $phone = $$args{phone} = ''; $celltype = $$args{celltype} = ''; } if (@errors) { &updateErrors($dbh,$args,\@errors); exit; } $$args{link} =~ s/\s+//g; $$args{link} =~ s/^http:\/\///i; my $what = $dbh->quote("$$args{first}:$$args{nickname}:$$args{occupation}:$$args{bday}:$$args{hometown}:$$args{email}:$$args{message}:SM$snakemail:$phone:$celltype"); my $firstInit = substr($$args{first},0,1); if ($$args{pin} > 0) { $$args{addressChange} = '0'; $$args{emailChange} = '0'; &checkAddressChange($dbh,$args); } my $rows; if ($status =~ /[PJ]/i || $$args{pin} < 0) { $rows = $dbh->do("update members set first = ?, nickname = ?, occupation = ?, phone = ?, celltype = ?, bday = ?, hometown = ?, email = ?, snakemail = ?, message = ?, link = ?, linkname = ?, password1 = ?, ip = ?, reg = 'Y', lastupdate = now() where recnum = ? and last = ? and status in ('P','J')",{}, $$args{first},$$args{nickname},$$args{occupation}, $$args{phone},$celltype,$$args{bday},$$args{hometown},$$args{email}, $snakemail,$$args{message},$$args{link},$$args{namelink}, $$args{youknow1},$ENV{REMOTE_ADDR},$$args{RECNUM},$$args{last}); } else { $rows = $dbh->do("update members set status = ?, first = ?, nickname = ?, occupation = ?, phone = ?, celltype = ?, bday = ?, hometown = ?, email = ?, snakemail = ?, snailmail = ?, message = ?, link = ?, linkname = ?, password1 = ?, password2 = ?, password3 = ?, address1 = ?, address2 = ?, city = ?, state = ?, zip = ?, ip = ?, reg = 'Y', lastupdate = now() where recnum = ? and pin = ?",{}, $status,$$args{first},$$args{nickname},$$args{occupation}, $$args{phone},$celltype,$$args{bday},$$args{hometown},$$args{email}, $snakemail,$$args{snailmail},$$args{message},$$args{link},$$args{namelink}, $$args{youknow1},$$args{youknow2},$$args{youknow3}, $$args{address1},$$args{address2},$$args{city},$$args{state},$$args{zip}, $ENV{REMOTE_ADDR},$$args{RECNUM},$$args{pin}); #print "ROWS: $rows DB:" . $dbh->errstr . "\n"; if ($$args{pin} > 0) { $dbh->do("delete from blocklist where pin = ?",{},$$args{pin}); my @blocklist = split(/\D+/,$$args{blocklist}); foreach my $block (@blocklist) { if ($block =~ /\d/ && $block ne $$args{pin}) { $dbh->do("insert into blocklist (pin,block) values (?,?)",{},$$args{pin},$block); } } } } if ($rows == 1) { &popFromDB($dbh,$args); $rows = $dbh->do("insert into plog (pin,action,tstamp, what, ip,host) values ($$args{pin},'UPDATE',NULL, $what, '$ENV{REMOTE_ADDR}','$ENV{REMOTE_HOST}')"); print "

UPDATE SUCCESSFUL

"; # HMMMMMMMMM if ($$args{youknow} ne $$args{youknow1} && $$args{youknow} ne $$args{youknow2} && $$args{youknow} ne $$args{youknow3} ) { $$args{youknow} = $$args{youknow1}; } if ($$args{emailChange}) { &emailChangeNotification($dbh,$args,$$args{first},$$args{last},$$args{email}); } if ($$args{addressChange}) { &addressChangeNotificaton($dbh,$args,$$args{first},$$args{last}, $$args{address1},$$args{address2}, $$args{city},$$args{state},$$args{zip},$$args{snailmail}); } #$updateSuccess = 'Y'; ? } &updateForm($dbh,$args); } sub sayName { my ($name, $status) = @_; my $nom; my $rand = rand(100); if ( $rand < 10 && $status !~ /X/i ) { if ($status =~ /P/i) { $nom = 'butthead'; } else { $nom = 'playa'; } } elsif ($rand > 98) { $nom = 'playa'; } if (!$nom) { if ($name =~ /\bA[\.\s]*J\b/i) { $name = 'AJ'; } else { $name =~ s/[^a-z ]/ /ig; ($name) = $name =~ /([A-Z]{2,})/i; } my $url = "http://www.fast.info/nom.pl?n=$name"; $ua->timeout(40); $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)'); $nom = get($url); $nom =~ s/<\/?html>//g; #my $status = getstore($url,$nom); } $nom ||= 'playa'; print <