package SPA2017winterCONFIRM;
my $path="../../../";
my $apath="./";
my $title="Online Abstract Submission";
my $header = $title;
!>
#include ../../../includes/wp-spa-header.iphtml
#include ./includes/abstract_header.iphtml
my %States=0;
my $Current_Screen=0;
%States = (
'Default' => \&first_page,
'Submit' => \&submit_page,
'Send Another Verification Email' => \&send_email_page,
);
$Current_Screen = $main::cgi->param("Submit") || "Default";
die "No screen for $Current_Screen" unless $States{$Current_Screen};
while (my($screen_name, $function) = each %States) {
$function->($screen_name eq $Current_Screen);
}
sub first_page {
my $active = shift;
return unless $active;
# collect email, connum, password
!>
Please verify your registration and create a password:
} # end first_page
sub submit_page {
my $active = shift;
return unless $active;
# foreach ($main::cgi->param) {
# print $_ . "==>" . $main::cgi->param($_) . "
";
# }
# check email and connum in db
my $SQL = "SELECT COUNT(username) from primary_contacts WHERE username=" . $main::dbh->quote($main::cgi->param('email')) . " AND conID =" . $main::dbh->quote($main::cgi->param('conID'));
# print "$SQL
";
my $cursor = $main::dbh->prepare($SQL);
$cursor->execute;
my $count = $cursor->fetchrow;
$cursor->finish;
if($count < 1) {
print "ERROR--Please make sure you have entered your email address and verification number correctly";
&first_page(1);
return;
}
# check password and password2
if ($main::cgi->param('password') ne $main::cgi->param('password2')) {
print "ERROR--Passwords did not match";
&first_page(1);
return;
}
#check confirmed status
$SQL = "SELECT COUNT(username) from mysql_auth WHERE username=" . $main::dbh->quote($main::cgi->param('email'));
# print "$SQL
";
$cursor = $main::dbh->prepare($SQL);
$cursor->execute;
$count = $cursor->fetchrow;
$cursor->finish;
# print "$count
";
if ($count > 0) {
print "ERROR -- This email address has already been confirmed. Please login. If you have forgotten your password, please visit the Lost Password Page";
&first_page(1);
return;
}
# insert username password and group
$SQL = "INSERT INTO mysql_auth(username, passwd, groups) VALUES (" . $main::dbh->quote($main::cgi->param('email')) . ", " . $main::dbh->quote($main::cgi->param('password')) . ", \"submit\")";
# print "$SQL
";
$cursor = $main::dbh->prepare($SQL);
$cursor->execute;
my $count = $cursor->rows;
if ($count == 1) {
my $SQL1 = "SELECT olduserID FROM primary_contacts WHERE username = " . $main::dbh->quote($main::cgi->param('email'));
my $cursor1 = $main::dbh->prepare($SQL1);
$cursor1->execute;
my $olduserID = $cursor1->fetchrow;
my $numabstracts;
$cursor1->finish;
if ($olduserID) {
$SQL1 = "UPDATE abstracts SET contactID = " . $main::dbh->quote($main::cgi->param('email')) . " WHERE contactID = \"$olduserID\"";
$cursor1 = $main::dbh->prepare($SQL1);
$cursor1->execute;
$numabstracts = $cursor1->rows;
$cursor1->finish;
}
!>
Registration Confirmed
Your username is your email address.
if ($numabstracts > 0) {
print "" . $numabstracts . " abstract(s) were transfered to this username from " . $olduserID . "";
}
!>
Please Login
} else {
print $cursor->errstr . "
";
print $cursor->err . "
";
print $cursor->state . "
";
print "There has been a database error";
print "Please contact the server administrator at webmaster\@societyhq.com";
}
$cursor->finish;
} # end submit_page
sub send_email_page {
my $active = shift;
return unless $active;
my $SQL="SELECT username, conID FROM primary_contacts WHERE username=" . $main::dbh->quote($main::cgi->param('email'));
my $cursor = $main::dbh->prepare($SQL);
$cursor->execute;
my ($email, $connum) = $cursor->fetchrow;
my $rows = $cursor->rows;
$cursor->finish;
$SQL="SELECT COUNT(username) FROM mysql_auth WHERE username=" . $main::dbh->quote($main::cgi->param('email'));
$cursor = $main::dbh->prepare($SQL);
$cursor->execute;
my $count = $cursor->fetchrow;
$cursor->finish;
if (($rows == 1) && ($count == 0)) {
my $sender = $society . "_abstracts\@societyhq.com";
my $bcc = "leonard\@societyhq.com";
my $subject = uc($society) . " Online Abstract Registration";
my $URL = $ENV{"SCRIPT_SRC_URL"};
my $script = $ENV{"SCRIPT_SRC_URL_FILE"};
$URL =~ s/$script//;
$URL =~ s/submit\///;
$URL .= "confirm.iphtml";
my $confirmURL = $URL . "?conID=" . $connum . "&email=" .$main::cgi->escape($email);
my $IP = $ENV{"REMOTE_ADDR"};
# print "
$confirmURL
";
# foreach (%ENV) {
# print $_ . " ==> " . $ENV{$_} . "
";
# }
open (MAIL, "|/usr/lib/sendmail -oi -t") or die "can't fork sendmail: $!";
print MAIL <Please Login";
print "If you have lost your password or username, go to the Lost Password Page";
} elsif ($rows == 0) {
print "ERROR YOUR EMAIL ADDRESS HAS NOT BEEN REGISTERED";
}
} # end send_email_page
!>
#include ./includes/abstract_footer.iphtml
#include ../../../includes/wp-spa-footer.iphtml