function newFund($username, $password, $xml_url, $user_email, $fundName, $numMembers, $stateLaw, $fundAddressCareOf, $fundAddressLevel, $fundAddressStreet, $fundAddressSuburb, $fundAddressState, $fundAddressPostcode, $teeMtgAddressLevel, $teeMtgAddressStreet, $teeMtgAddressSuburb, $teeMtgAddressState, $teeMtgAddressPostcode, $m1MemberNamePrefix, $m1MemberGivenNames, $m1MemberFamilyName, $m1MemberDOB, $m1MemberTFN, $m1AddressLevel, $m1AddressStreet, $m1AddressSuburb, $m1AddressState, $m1AddressPostcode, $m2MemberNamePrefix, $m2MemberGivenNames, $m2MemberFamilyName, $m2MemberDOB, $m2MemberTFN, $m2AddressLevel, $m2AddressStreet, $m2AddressSuburb, $m2AddressState, $m2AddressPostcode, $m3MemberNamePrefix, $m3MemberGivenNames, $m3MemberFamilyName, $m3MemberDOB, $m3MemberTFN, $m3AddressLevel, $m3AddressStreet, $m3AddressSuburb, $m3AddressState, $m3AddressPostcode, $m4MemberNamePrefix, $m4MemberGivenNames, $m4MemberFamilyName, $m4MemberDOB, $m4MemberTFN, $m4AddressLevel, $m4AddressStreet, $m4AddressSuburb, $m4AddressState, $m4AddressPostcode, $t2NonMemberNamePrefix, $t2NonMemberGivenNames, $t2NonMemberFamilyName, $t2NonMemberAddressLevel, $t2NonMemberAddressStreet, $t2NonMemberAddressSuburb, $t2NonMemberAddressState, $t2NonMemberAddressPostcode, $corpTeeName, $corpTeeACN, $corpTeeAddressCareOf, $corpTeeAddressLevel, $corpTeeAddressStreet, $corpTeeAddressSuburb, $corpTeeAddressState, $corpTeeAddressPostcode, $d2NonMemberNamePrefix, $d2NonMemberGivenNames, $d2NonMemberFamilyName, $d2NonMemberAddressLevel, $d2NonMemberAddressStreet, $d2NonMemberAddressSuburb, $d2NonMemberAddressState, $d2NonMemberAddressPostcode, $chairmanTrustee) { $ch = curl_init(); $timeout = 3600; curl_setopt($ch, CURLOPT_URL, $xml_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); // $response = curl_getinfo($ch); curl_close($ch); $xml = simplexml_load_string($data); if (!simplexml_load_string($data) && !$xml) { global $wpdb; $wp_hasher = new PasswordHash(8, TRUE); $sql = "SELECT * FROM wp_users WHERE user_login = '******' "; $resultuser = $wpdb->get_results($sql); if ($resultuser) { foreach ($resultuser as $results) { if ($wp_hasher->CheckPassword($password, $results->user_pass)) { $unique = trim(com_create_guid(), '{}'); $result = $wpdb->insert('service_nsf', array('unique_code' => $unique, 'user_email' => $user_email, 'fundName' => $fundName, 'numMembers' => $numMembers, 'stateLaw' => $stateLaw, 'fundAddressCareOf' => $fundAddressCareOf, 'fundAddressLevel' => $fundAddressLevel, 'fundAddressStreet' => $fundAddressStreet, 'fundAddressSuburb' => $fundAddressSuburb, 'fundAddressState' => $fundAddressState, 'fundAddressPostcode' => $fundAddressPostcode, 'teeMtgAddressLevel' => $teeMtgAddressLevel, 'teeMtgAddressStreet' => $teeMtgAddressStreet, 'teeMtgAddressSuburb' => $teeMtgAddressSuburb, 'teeMtgAddressState' => $teeMtgAddressState, 'teeMtgAddressPostcode' => $teeMtgAddressPostcode, 'm1MemberNamePrefix' => $m1MemberNamePrefix, 'm1MemberGivenNames' => $m1MemberGivenNames, 'm1MemberFamilyName' => $m1MemberFamilyName, 'm1MemberDOB' => $m1MemberDOB, 'm1MemberTFN' => $m1MemberTFN, 'm1AddressLevel' => $m1AddressLevel, 'm1AddressStreet' => $m1AddressStreet, 'm1AddressSuburb' => $m1AddressSuburb, 'm1AddressState' => $m1AddressState, 'm1AddressPostcode' => $m1AddressPostcode, 'm2MemberNamePrefix' => $m2MemberNamePrefix, 'm2MemberGivenNames' => $m2MemberGivenNames, 'm2MemberFamilyName' => $m2MemberFamilyName, 'm2MemberDOB' => $m2MemberDOB, 'm2MemberTFN' => $m2MemberTFN, 'm2AddressLevel' => $m2AddressLevel, 'm2AddressStreet' => $m2AddressStreet, 'm2AddressSuburb' => $m2AddressSuburb, 'm2AddressState' => $m2AddressState, 'm2AddressPostcode' => $m2AddressPostcode, 'm3MemberNamePrefix' => $m3MemberNamePrefix, 'm3MemberGivenNames' => $m3MemberGivenNames, 'm3MemberFamilyName' => $m3MemberFamilyName, 'm3MemberDOB' => $m3MemberDOB, 'm3MemberTFN' => $m3MemberTFN, 'm3AddressLevel' => $m3AddressLevel, 'm3AddressStreet' => $m3AddressStreet, 'm3AddressSuburb' => $m3AddressSuburb, 'm3AddressState' => $m3AddressState, 'm3AddressPostcode' => $m3AddressPostcode, 'm4MemberNamePrefix' => $m4MemberNamePrefix, 'm4MemberGivenNames' => $m4MemberGivenNames, 'm4MemberFamilyName' => $m4MemberFamilyName, 'm4MemberDOB' => $m4MemberDOB, 'm4MemberTFN' => $m4MemberTFN, 'm4AddressLevel' => $m4AddressLevel, 'm4AddressStreet' => $m4AddressStreet, 'm4AddressSuburb' => $m4AddressSuburb, 'm4AddressState' => $m4AddressState, 'm4AddressPostcode' => $m4AddressPostcode, 't2NonMemberNamePrefix' => $t2NonMemberNamePrefix, 't2NonMemberGivenNames' => $t2NonMemberGivenNames, 't2NonMemberFamilyName' => $t2NonMemberFamilyName, 't2NonMemberAddressLevel' => $t2NonMemberAddressLevel, 't2NonMemberAddressStreet' => $t2NonMemberAddressStreet, 't2NonMemberAddressSuburb' => $t2NonMemberAddressSuburb, 't2NonMemberAddressState' => $t2NonMemberAddressState, 't2NonMemberAddressPostcode' => $t2NonMemberAddressPostcode, 'corpTeeName' => $corpTeeName, 'corpTeeACN' => $corpTeeACN, 'corpTeeAddressCareOf' => $corpTeeAddressCareOf, 'corpTeeAddressLevel' => $corpTeeAddressLevel, 'corpTeeAddressStreet' => $corpTeeAddressStreet, 'corpTeeAddressSuburb' => $corpTeeAddressSuburb, 'corpTeeAddressState' => $corpTeeAddressState, 'corpTeeAddressPostcode' => $corpTeeAddressPostcode, 'd2NonMemberNamePrefix' => $d2NonMemberNamePrefix, 'd2NonMemberGivenNames' => $d2NonMemberGivenNames, 'd2NonMemberFamilyName' => $d2NonMemberFamilyName, 'd2NonMemberAddressLevel' => $d2NonMemberAddressLevel, 'd2NonMemberAddressStreet' => $d2NonMemberAddressStreet, 'd2NonMemberAddressSuburb' => $d2NonMemberAddressSuburb, 'd2NonMemberAddressState' => $d2NonMemberAddressState, 'd2NonMemberAddressPostcode' => $d2NonMemberAddressPostcode, 'chairmanTrustee' => $chairmanTrustee), array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); return array('unique_code' => $unique); } else { return array('username' => 'Invalid username or password1'); } } } else { return array('username' => 'Invalid username or password2' . $result); } } else { return @nsf_parser($username, $password, $xml_url); } }
function newFund($parameters) { $response = array('status' => array('code' => '', 'message' => ''), 'uniqueID' => ''); $username = $parameters['username']; $password = $parameters['password']; $trusteeType = $parameters['fund']['trustee']['type']; $chairman = $parameters['fund']['trustee']['chairman']; $memberCount = 0; if ($trusteeType == 'Individuals') { //individual trustees $person_1 = $parameters['fund']['trustee']['individual_1']; if ($person_1['isMember'] == 1) { $memberCount = $memberCount + 1; $member_1 = $person_1; } $person_2 = $parameters['fund']['trustee']['individual_2']; if ($person_2['isMember'] == 1) { $memberCount = $memberCount + 1; $member_2 = $person_2; } else { $nmTrustee = $person_2; } $person_3 = $parameters['fund']['trustee']['individual_3']; if ($person_3['isMember'] == 1) { $memberCount = $memberCount + 1; $member_3 = $person_3; } $person_4 = $parameters['fund']['trustee']['individual_4']; if ($person_4['isMember'] == 1) { $memberCount = $memberCount + 1; $member_4 = $person_4; } } else { //directors of corporate trustee $person_1 = $parameters['fund']['trustee']['corporate']['oh1']; if ($person_1['roles']['member'] = 1) { $memberCount = $memberCount + 1; $member_1 = $person_1; } $person_2 = $parameters['fund']['trustee']['corporate']['oh2']; if ($person_2['roles']['member'] = 1) { $memberCount = $memberCount + 1; $member_2 = $person_2; } else { $nmDirector = $person_2; } $person_3 = $parameters['fund']['trustee']['corporate']['oh3']; if ($person_3['roles']['member'] = 1) { $memberCount = $memberCount + 1; $member_3 = $person_3; } $person_4 = $parameters['fund']['trustee']['corporate']['oh4']; if ($person_4['roles']['member'] = 1) { $memberCount = $memberCount + 1; $member_4 = $person_4; } } switch ($chairman) { case 1: $chair = $person_1['givenNames'] . ' ' . $person_1['familyName']; break; case 2: $chair = $person_2['givenNames'] . ' ' . $person_2['familyName']; break; case 3: $chair = $person_3['givenNames'] . ' ' . $person_3['familyName']; break; case 4: $chair = $person_4['givenNames'] . ' ' . $person_4['familyName']; break; } $ch = curl_init(); $timeout = 3600; curl_setopt($ch, CURLOPT_URL, $xml_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); // $response = curl_getinfo($ch); curl_close($ch); $xml = simplexml_load_string($data); if (!simplexml_load_string($data) && !$xml) { global $wpdb; $wp_hasher = new PasswordHash(8, TRUE); $sql = "SELECT * FROM wp_users WHERE user_login = '******' "; $resultuser = $wpdb->get_results($sql); if ($resultuser) { foreach ($resultuser as $results) { if ($wp_hasher->CheckPassword($password, $results->user_pass)) { $unique = trim(com_create_guid(), '{}'); $result = $wpdb->insert('service_nsf', array('unique_code' => $unique == "?" ? '' : $unique, 'user_email' => $parameters['username'] == "?" ? '' : $parameters['username'], 'fundName' => $parameters['fund']['name'] == "?" ? '' : $parameters['fund']['name'], 'numMembers' => $memberCount == "?" ? '' : $memberCount, 'stateLaw' => $parameters['fund']['stateLaw'] == "?" ? '' : $parameters['fund']['stateLaw'], 'fundAddressCareOf' => $parameters['fund']['address']['careOf'] == "?" ? '' : $parameters['fund']['address']['careOf'], 'fundAddressLevel' => $parameters['fund']['address']['level'] == "?" ? '' : $parameters['fund']['address']['level'], 'fundAddressStreet' => $parameters['fund']['address']['street'] == "?" ? '' : $parameters['fund']['address']['street'], 'fundAddressSuburb' => $parameters['fund']['address']['suburb'] == "?" ? '' : $parameters['fund']['address']['suburb'], 'fundAddressState' => $parameters['fund']['address']['state'] == "?" ? '' : $parameters['fund']['address']['state'], 'fundAddressPostcode' => $parameters['fund']['address']['postcode'] == "?" ? '' : $parameters['fund']['address']['postcode'], 'teeMtgAddressLevel' => $parameters['fund']['trustee']['meetingAddress']['level'] == "?" ? '' : $parameters['fund']['trustee']['meetingAddress']['level'], 'teeMtgAddressStreet' => $parameters['fund']['trustee']['meetingAddress']['street'] == "?" ? '' : $parameters['fund']['trustee']['meetingAddress']['street'], 'teeMtgAddressSuburb' => $parameters['fund']['trustee']['meetingAddress']['suburb'] == "?" ? '' : $parameters['fund']['trustee']['meetingAddress']['suburb'], 'teeMtgAddressState' => $parameters['fund']['trustee']['meetingAddress']['state'] == "?" ? '' : $parameters['fund']['trustee']['meetingAddress']['state'], 'teeMtgAddressPostcode' => $parameters['fund']['trustee']['meetingAddress']['postcode'] == "?" ? '' : $parameters['fund']['trustee']['meetingAddress']['postcode'], 'm1MemberNamePrefix' => $member_1['title'] == "?" ? '' : $member_1['title'], 'm1MemberGivenNames' => $member_1['givenNames'] == "?" ? '' : $member_1['givenNames'], 'm1MemberFamilyName' => $member_1['familyName'] == "?" ? '' : $member_1['familyName'], 'm1MemberDOB' => $member_1['DOB'] == "?" ? '' : $member_1['DOB'], 'm1MemberTFN' => $member_1['TFN'] == "?" ? '' : $member_1['TFN'], 'm1AddressLevel' => $member_1['address']['level'] == "?" ? '' : $member_1['address']['level'], 'm1AddressStreet' => $member_1['address']['street'] == "?" ? '' : $member_1['address']['street'], 'm1AddressSuburb' => $member_1['address']['suburb'] == "?" ? '' : $member_1['address']['suburb'], 'm1AddressState' => $member_1['address']['state'] == "?" ? '' : $member_1['address']['state'], 'm1AddressPostcode' => $member_1['address']['postcode'] == "?" ? '' : $member_1['address']['postcode'], 'm2MemberNamePrefix' => $member_2['title'] == "?" ? '' : $member_2['title'], 'm2MemberGivenNames' => $member_2['givenNames'] == "?" ? '' : $member_2['givenNames'], 'm2MemberFamilyName' => $member_2['familyName'] == "?" ? '' : $member_2['familyName'], 'm2MemberDOB' => $member_2['DOB'] == "?" ? '' : $member_2['DOB'], 'm2MemberTFN' => $member_2['TFN'] == "?" ? '' : $member_2['TFN'], 'm2AddressLevel' => $member_2['address']['level'] == "?" ? '' : $member_2['address']['level'], 'm2AddressStreet' => $member_2['address']['street'] == "?" ? '' : $member_2['address']['street'], 'm2AddressSuburb' => $member_2['address']['suburb'] == "?" ? '' : $member_2['address']['suburb'], 'm2AddressState' => $member_2['address']['state'] == "?" ? '' : $member_2['address']['state'], 'm2AddressPostcode' => $member_2['address']['postcode'] == "?" ? '' : $member_2['address']['postcode'], 'm3MemberNamePrefix' => $member_3['title'] == "?" ? '' : $member_3['title'], 'm3MemberGivenNames' => $member_3['givenNames'] == "?" ? '' : $member_3['givenNames'], 'm3MemberFamilyName' => $member_3['familyName'] == "?" ? '' : $member_3['familyName'], 'm3MemberDOB' => $member_3['DOB'] == "?" ? '' : $member_3['DOB'], 'm3MemberTFN' => $member_3['TFN'] == "?" ? '' : $member_3['TFN'], 'm3AddressLevel' => $member_3['address']['level'] == "?" ? '' : $member_3['address']['level'], 'm3AddressStreet' => $member_3['address']['street'] == "?" ? '' : $member_3['address']['street'], 'm3AddressSuburb' => $member_3['address']['suburb'] == "?" ? '' : $member_3['address']['suburb'], 'm3AddressState' => $member_3['address']['state'] == "?" ? '' : $member_3['address']['state'], 'm3AddressPostcode' => $member_3['address']['postcode'] == "?" ? '' : $member_3['address']['postcode'], 'm4MemberNamePrefix' => $member_4['title'] == "?" ? '' : $member_4['title'], 'm4MemberGivenNames' => $member_4['givenNames'] == "?" ? '' : $member_4['givenNames'], 'm4MemberFamilyName' => $member_4['familyName'] == "?" ? '' : $member_4['familyName'], 'm4MemberDOB' => $member_4['DOB'] == "?" ? '' : $member_4['DOB'], 'm4MemberTFN' => $member_4['TFN'] == "?" ? '' : $member_4['TFN'], 'm4AddressLevel' => $member_4['address']['level'] == "?" ? '' : $member_4['address']['level'], 'm4AddressStreet' => $member_4['address']['street'] == "?" ? '' : $member_4['address']['street'], 'm4AddressSuburb' => $member_4['address']['suburb'] == "?" ? '' : $member_4['address']['suburb'], 'm4AddressState' => $member_4['address']['state'] == "?" ? '' : $member_4['address']['state'], 'm4AddressPostcode' => $member_4['address']['postcode'] == "?" ? '' : $member_4['address']['postcode'], 't2NonMemberNamePrefix' => $nmTrustee['title'] == "?" ? '' : $nmTrustee['title'], 't2NonMemberGivenNames' => $nmTrustee['givenNames'] == "?" ? '' : $nmTrustee['givenNames'], 't2NonMemberFamilyName' => $nmTrustee['familyName'] == "?" ? '' : $nmTrustee['familyName'], 't2NonMemberAddressLevel' => $nmTrustee['address']['level'] == "?" ? '' : $nmTrustee['address']['level'], 't2NonMemberAddressStreet' => $nmTrustee['address']['street'] == "?" ? '' : $nmTrustee['address']['street'], 't2NonMemberAddressSuburb' => $nmTrustee['address']['suburb'] == "?" ? '' : $nmTrustee['address']['suburb'], 't2NonMemberAddressState' => $nmTrustee['address']['state'] == "?" ? '' : $nmTrustee['address']['state'], 't2NonMemberAddressPostcode' => $nmTrustee['address']['postcode'] == "?" ? '' : $nmTrustee['address']['postcode'], 'corpTeeName' => $parameters['fund']['trustee']['corporate']['companyName'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['companyName'], 'corpTeeACN' => $parameters['fund']['trustee']['corporate']['acn'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['acn'], 'corpTeeAddressCareOf' => $parameters['fund']['trustee']['corporate']['roAddress']['careOf'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['roAddress']['careOf'], 'corpTeeAddressLevel' => $parameters['fund']['trustee']['corporate']['roAddress']['level'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['roAddress']['level'], 'corpTeeAddressStreet' => $parameters['fund']['trustee']['corporate']['roAddress']['street'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['roAddress']['street'], 'corpTeeAddressSuburb' => $parameters['fund']['trustee']['corporate']['roAddress']['suburb'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['roAddress']['suburb'], 'corpTeeAddressState' => $parameters['fund']['trustee']['corporate']['roAddress']['state'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['roAddress']['state'], 'corpTeeAddressPostcode' => $parameters['fund']['trustee']['corporate']['roAddress']['postcode'] == "?" ? '' : $parameters['fund']['trustee']['corporate']['roAddress']['postcode'], 'd2NonMemberNamePrefix' => $nmDirector['title'] == "?" ? '' : $nmDirector['title'], 'd2NonMemberGivenNames' => $nmDirector['givenNames'] == "?" ? '' : $nmDirector['givenNames'], 'd2NonMemberFamilyName' => $nmDirector['familyName'] == "?" ? '' : $nmDirector['familyName'], 'd2NonMemberAddressLevel' => $nmDirector['address']['level'] == "?" ? '' : $nmDirector['address']['level'], 'd2NonMemberAddressStreet' => $nmDirector['address']['street'] == "?" ? '' : $nmDirector['address']['street'], 'd2NonMemberAddressSuburb' => $nmDirector['address']['suburb'] == "?" ? '' : $nmDirector['address']['state'], 'd2NonMemberAddressState' => $nmDirector['address']['state'] == "?" ? '' : $nmDirector['address']['postcode'], 'd2NonMemberAddressPostcode' => $nmDirector['address']['postcode'] == "?" ? '' : $nmDirector, 'chairmanTrustee' => $chair == "?" ? '' : $chair, 'yourRef' => $parameters['yourRef'] == "?" ? '' : $parameters['yourRef'], 'trusteeType' => $parameters['trusteeType'] == "?" ? '' : $parameters['trusteeType']), array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); $response['status']['code'] = 200; $response['status']['message'] = 'Submission successful'; $response['uniqueID'] = $unique; return $response; } else { $response['status']['code'] = 401; } $response['status']['message'] = 'Unauthorised - Bad password'; $response['uniqueID'] = ''; return $response; } } else { $response['status']['code'] = 401; $response['status']['message'] = 'Unauthorised - Bad username'; $response['uniqueID'] = ''; return $response; } } else { return @nsf_parser($username, $password, $xml_url); } }