Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
Add a new member renew function
· 383ecf63
Imran Hussain
authored
Oct 06, 2015
383ecf63
Make my redo of the su signup page use the new membership renew function
· 71feb742
Imran Hussain
authored
Oct 06, 2015
71feb742
Hide whitespace changes
Inline
Side-by-side
components/susignup.php
View file @
71feb742
...
...
@@ -6,7 +6,7 @@
// this is the php for sucs.org/susignup
// Include shit we need.
// Include shit we need.
like the renew_membership fucntion
include
"../lib/member_functions.php"
;
include
"../lib/date.php"
;
...
...
@@ -39,8 +39,8 @@ if(!empty($_REQUEST['sid'])&&!empty($_REQUEST['transactionID'])){
trigger_error
(
"You are a numpty and have already signed up and paid for this year."
,
E_USER_ERROR
);
// else if check to see if they have signedup and paid for the new year but haven't renewed
}
else
if
(
$tmpresult
->
fields
[
"sid"
]
==
$sid
&&
$tmpresult
->
fields
[
"paid"
]
!=
paidUntil
(
time
())){
//
update our db to indicate that they ahev paid for thsi year
$sucsDB
->
Execute
(
"UPDATE members SET paid=?, lastupdate=DEFAULT, lastedit=? WHERE sid=?"
,
array
(
paidUntil
(
time
()),
"99999"
,
$sid
)
);
//
renew them!
renew_membership
(
$tmpresult
->
fields
[
"username"
]
);
// let them know that their account has been renewed
trigger_error
(
"Your SUCS account has been renewed."
,
E_USER_INFO
);
// else if they aren't in the SUCS DB but have a signup slip, take them back to that part of signup
...
...
lib/member_functions.php
View file @
71feb742
...
...
@@ -107,4 +107,31 @@ function generateLdif($uid, $password, $type, $realname, $username){
return
$ldif
;
}
// function to renew a persons sucs membership
renew_membership
(
$username
)
{
// get their details from the sucs db
$userdata
=
$sucsDB
->
Execute
(
"SELECT * FROM members WHERE username=?"
,
array
(
$username
));
// include the date file so we can call the paidUntil function
include_once
(
"date.php"
);
// Update their record in the DB
$sucsDB
->
Execute
(
"UPDATE members SET paid=?, lastupdate=DEFAULT, lastedit=? WHERE username=?"
,
array
(
paidUntil
(
time
()),
"99999"
,
$username
));
// Give them their 200 print credits
exec
(
"/usr/local/sbin/printerrenew.apache ${username} 200"
);
// apprently sending them an email confirming so is nice
$message
=
"Your Swansea University Computer Society (SUCS) membership has been renewed
\n\n
"
;
$message
.
=
"Username: ${username}
\n
"
;
$message
.
=
"If you do not know or have forgotten your password, please email admin@sucs.org to arrange for it to be changed.
\n\n
"
;
$message
.
=
"Regards
\n
The SUCS admin"
;
$header
=
"From: admin@sucs.org
\r\n
"
;
$header
.
=
"Reply-To: admin@sucs.org"
;
// send it to their personal account
mail
(
$userdata
->
fields
[
'email'
],
"SUCS account renewal"
,
$message
,
$header
);
}
?>