Skip to content
Snippets Groups Projects
Commit 1cb19191 authored by Imran Hussain's avatar Imran Hussain
Browse files

add comments!

parent 54fbd6ee
No related branches found
No related tags found
3 merge requests!28Push SU-APIv2 stuff to live,!27Push SUAPIv2 code to beta,!25Implement the new SU API Closes #5
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
// sorry // sorry
// gib errars plox
error_reporting(E_ALL); error_reporting(E_ALL);
ini_set('display_errors', 1); ini_set('display_errors', 1);
// without this the entire thing doesn't work
include_once("../suapiv2-key.php"); include_once("../suapiv2-key.php");
//SUCS Org ID According to the SU //SUCS Org ID According to the SU
...@@ -12,37 +15,51 @@ $orgid = "6613"; ...@@ -12,37 +15,51 @@ $orgid = "6613";
$apibaseurl = "http://su-apiv2.sucs.org/?apikey=${apikey}&orgid=${orgid}"; $apibaseurl = "http://su-apiv2.sucs.org/?apikey=${apikey}&orgid=${orgid}";
// Get the shit json the suapiv2 spits out
$ch = curl_init($apibaseurl); $ch = curl_init($apibaseurl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
$raw_data = curl_exec($ch); $raw_data = curl_exec($ch);
curl_close($ch); curl_close($ch);
$formated_raw_data = json_decode($raw_data, true); $formated_raw_data = json_decode($raw_data, true); //convert it into php arrays
$membership_data = $formated_raw_data["table1"]["table1_Product_Collection"]["table1_Product"]; $membership_data = $formated_raw_data["table1"]["table1_Product_Collection"]["table1_Product"]; //$membership_data is an array where each type of memebrship is it;s own array
// make a new array that just contains *every* member no matter what they bought
$just_members = array(); $just_members = array();
foreach ($membership_data as $typeOfMember) { foreach ($membership_data as $typeOfMember) {
foreach ($typeOfMember["Detail_Collection"]["Detail"] as $member) { foreach ($typeOfMember["Detail_Collection"]["Detail"] as $member) {
array_push($just_members, $member["@attributes"]); array_push($just_members, $member["@attributes"]);
} }
} }
/* You can now use $just_members to probe member detials. It's an array of arrays which each contain:
function check_SU_trans($sid, $transid) { * transaction_id (recepit id)
* purchaser (full name)
* textbox6 (under 18 or not) NOT SURE OF THE FORMAT
* card_number (student number)
* shop_name (where they bought sucs memebrship)
* qty (how many sucs memebrships they bought)
* purchase_date (timestamp of when they bought memebrship)4
*/
/*
* Used by /susignup to verify that the stduent number and transaction id combo are valid
* returns true or false
*/
function check_su_trans($sid, $transid) {
global $just_members; global $just_members;
foreach ($just_members as $member) { foreach ($just_members as $member) {
if ($sid == $member["card_number"] && $transid == $member["transaction_id"]) { if ($sid == $member["card_number"] && $transid == $member["transaction_id"]) {
return true; return true;
} }
} }
return false; return false;
} }
function check_SU_SID($sid) { /*
* Used to verify taht a given stduent number has paid for membership via the su system.
* returns false or true
*/
function check_su_sid($sid) {
global $just_members; global $just_members;
foreach ($just_members as $member) { foreach ($just_members as $member) {
if ($sid == $member["card_number"]) { if ($sid == $member["card_number"]) {
...@@ -50,8 +67,6 @@ function check_SU_SID($sid) { ...@@ -50,8 +67,6 @@ function check_SU_SID($sid) {
} }
} }
return false; return false;
} }
?> ?>
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