Skip to content
Snippets Groups Projects
Commit af20c0a7 authored by Callum Massey's avatar Callum Massey
Browse files

Final pre-freshers fayre update. Now fully functional!

parent 28621234
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ $GroupingID = "6613";
include "../lib/member_functions.php";
include "../suapi.inc.php";
$error_email = "admin@sucs.org";
$mode = 'login';
//login
if(!empty($_REQUEST['sid'])&&!empty($_REQUEST['transactionID'])){
......@@ -35,11 +35,10 @@ if(!empty($_REQUEST['sid'])&&!empty($_REQUEST['transactionID'])){
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
if(!$result){
//HTTP Error
}else{
$re1='.*?';
$re2='(\\{.*?\\})';
......@@ -49,9 +48,7 @@ if(!empty($_REQUEST['sid'])&&!empty($_REQUEST['transactionID'])){
}else{
//ERROR
}
$array = json_decode($json_string,TRUE);
if($array['cardNumber'] == $sid && $sid != ""){
$mode = 'form';
......@@ -59,30 +56,76 @@ if(!empty($_REQUEST['sid'])&&!empty($_REQUEST['transactionID'])){
$sucsDB = NewADOConnection('postgres8');
// SET THIS FOR DEBUG MODE
$sucsDB->debug = true;
// $sucsDB->debug = true;
// SET THIS TO YOUR DB FOR TESTING
$sucsDB->Connect('dbname=sucs');
$sucsDB->Connect('dbname=sucs user=apache');
$sucsDB->SetFetchMode(ADODB_FETCH_ASSOC);
$query = "INSERT INTO transactions (transactionID,fullName,emailAddress,cardNumber,personID) values(?, ? ?, ?, ?, ?)";
$attribs[]=$transactionID;
$attribs[]=$array['firstName'];
$attribs[]=$array['lastName'];
$attribs[]=$array['emailAddress'];
$attribs[]=$array['cardNumber'];
$attribs[]=$array['personID'];
$sucsDB->SetFetchMode(ADODB_FETCH_ASSOC);
$fullName = $array['firstName']." ".$array['lastName'];
$query = "INSERT INTO transactions (transactionID,fullName,emailAddress,cardNumber,personID) values(?, ?, ?, ?, ?)";
$attribs[] = $transactionID;
$attribs[] = $fullName;
$attribs[] = $array['emailAddress'];
$attribs[] = $array['cardNumber'];
$attribs[] = $array['personID'];
$valid = true;
if(!$sucsDB->Execute($query,$attribs)) {
$query = "SELECT * FROM transactions WHERE transactionID = ? AND signupid IS NULL";
$attribs= array();
// We did this because Adodb ErrorNo command is broken
$query = "SELECT * FROM transactions WHERE transactionID = ?";
unset($attribs);
$attribs[]=$transactionID;
$data = $sucsDB->GetAll($query,$attribs);
if(is_array($data)&&sizeof($data)==1){
//ERROR SOMEONE TRIED TO USE SAME TRANSACTIONID TWICE SIGNUP SLIP ALREADY GENERATED
// MAIL ERROR MESSAGE THEN DIE
if($sucsDB->Execute($query,$attribs)) {
$query = "SELECT * FROM transactions WHERE transactionID = ?";
$attribs= array();
$attribs[]=$transactionID;
$data = $sucsDB->GetAll($query,$attribs);
if(is_array($data)&&sizeof($data)==1&&$data[0]['signupid']==NULL){
// As it stands this shouldn't happen but if it does, no reason not to let them carry on
$valid = true;
} elseif(is_array($data)&&sizeof($data)==1&&$data[0]['signupid']!=NULL) {
$query = "SELECT * FROM signup WHERE sid = ? AND username IS NULL";
unset($attribs);
$attribs[]=$sid;
$data = $sucsDB->Execute($query, $attribs);
if(!$data) {
//handle db err
print($sucsDB->ErrorMsg());
$valid=false;
} else if($data->RecordCount()==0) {
$smarty->assign("username", $data->fields['username']);
$mode='numpty2';
// This happens if they already ahve a SUCS account and are trying to create a new signupid
$valid = false;
} else {
$smarty->assign("id", $data->fields['id']);
$smarty->assign("pass", $data->fields['password']);
$mode='numpty';
// If this happens they tried to get a new signupid/pass after already getting one, and should get weekly reminders about it
$valid = false;
}
} else {
$mode="error";
mail(
$error_email,
"SUSignup Error",
"An error occured in the susignup system at stage 1\n Love the signup system.\n\nP.S. The Error is:\n ".$sucsDB->ErrorMsg(),
"From: \"SUCS Admin\" <admin@sucs.org>"
);
$valid = false;
}
} else {
$mode="error";
mail(
$error_email,
"SUSignup Error",
"An error occured in the susignup system at stage 2\n Love the signup system.\n\nP.S. The Error is:\n ".$sucsDB->ErrorMsg(),
"From: \"SUCS Admin\" <admin@sucs.org>"
);
$valid = false;
}
}
......@@ -95,25 +138,46 @@ if(!empty($_REQUEST['sid'])&&!empty($_REQUEST['transactionID'])){
unset($attribs);
$attribs[]=addslashes($pass);
$attribs[]=$array['cardNumber'];
$attribs[]='SUSU API';
$attribs[]='99999';
$id = $sucsDB->Execute($query,$attribs);
if (!$id) {
echo "Entering id $id failed.<br>\n".$sucsDB->ErrorMsg();
} else {
unset($query);
$query = "update transactions set signupid = ? WHERE transactionID = ?";
$id = $id->fields['id'];
if (!$id) {
$mode="error";
mail(
$error_email,
"SUSignup Error",
"An error occured in the susignup system at stage 3\n Love the signup system.\n\nP.S. The Error is:\n ".$sucsDB->ErrorMsg(),
"From: \"SUCS Admin\" <admin@sucs.org>"
);
} else {
$query = "update transactions set signupid=? WHERE transactionID=?";
unset($attribs);
$attribs[]=$id;
$attribs[]=$transactionID;
if(!$sucsDB->Execute($query,$attibs)) {
//ERROR
if(!$sucsDB->Execute($query,$attribs)) {
$mode="error";
mail(
$error_email,
"SUSignup Error",
"An error occured in the susignup system at stage 4\n Love the signup system.\n\nP.S. The Error is:\n ".$sucsDB->ErrorMsg(),
"From: \"SUCS Admin\" <admin@sucs.org>"
);
print($sucsDB->ErrorMsg());
} else {
$smarty->assign("id", $id);
$smarty->assign("pass", $pass);
mail(
$array['emailAddress'].','.$sid.'@swansea.ac.uk',
"SUCS Signup Information",
"Thankyou for joining Swansea University Computer Society, your signup details are below;\nSignupID: $id\nSignup Password: $pass\nIf you have successfully completed signup immediately then you can disregard this message.\n\nSUCS Admin Team.",
"From: \"SUCS Admin\" <admin@sucs.org>"
);
}
}
} else {
//ERROR
}
}
......
......@@ -4,7 +4,7 @@
<div class="boxhead"><h2>Membership Signup</h2></div>
<div class="boxcontent">
<p>Please enter transaction ID fromt eh email you received from the union after purchasing membership.</p>
<p>Please enter your Transation ID from the email you recieved from the Union after your purchase.</p>
<div class="row">
<label for="sid">Student Number:</label>
......@@ -27,19 +27,28 @@
<h1>Signup</h1>
<p>To continue signup later please use the link below to dispay and print off your signup slip</p>
<form action="https://sucs.org/~kais58/sucstest/sucs/generate.php" method="post" target="_blank">
<input type=hidden name="id" value={$id}/>
<input type=hidden name="pass" value={$pass}/>
<input type=hidden name="id" id="id" value="{$id}" />
<input type=hidden name="pass" id="pass" value="{$pass}" />
<input type=submit name="submit" value="Proceed" />
</form>
<p>To finish signup now click below to continue</p>
<form action="https://sucs.org/signup/" method="post">
<input type=hidden name="signupid" value={$id}/>
<input type=hidden name="signuppw" value={$pass}/>
<input type=hidden name="signupid" id="id" value="{$id}" />
<input type=hidden name="signuppw" id="pass" value="{$pass}" />
<input type=submit name="submit" value="Proceed" />
</form>
{elseif $mode=='numpty'}
<p>You appear to have completed this part of signup before, please check your emails for your signup ID and password. Alternatively click below to continue.</p>
<form action="https://sucs.org/signup/" method="post">
<input type=hidden name="signupid" id="id" value="{$id}" />
<input type=hidden name="signuppw" id="pass" value="{$pass}" />
<input type=submit name="submit" value="Proceed" />
</form>
{elseif $mode=='numpty2'}
<p>You appear to have already completed this step and registered with SUCS with the username <strong>{$username}</strong>.<br/>If you have forgotten your login password please email <a href='mailto:admin@sucs.org'>admin@sucs.org</a> or drop by the SUCS room and find an admin.</p>
{else}
<h1>Error</h1>
An error occured during signup, please email <a href='mailto:admin@sucs.org'>admin@sucs.org</a> for assistance.
An error occured during signup, please email, with as much information as you can provide, <a href='mailto:admin@sucs.org'>admin@sucs.org</a> for assistance.
{/if}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment