forked from pascalBokBok/OpenSourceMemberManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
37 lines (36 loc) · 1.13 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
try {
$response = array("payload"=>null);
if (!isset($_GET["action"])){
throw new Exception("You need to specify an action.");
}
require_once "backend/database.php";
if ($_GET["action"]=="getMemberList"){
$payload = getAllMembers();
} else if ($_GET["action"]=="addNewMember"){
$db = connect();
$member = $_GET;
unset($member['action']);
addNewMember($member);
} else if ($_GET["action"]=="updateMember"){
$db = connect();
$member = $_GET;
unset($member['action']);
updateMember($member);
} else if ($_GET["action"]=="deleteMember"){
deleteMember($_GET['id']);
} else if ($_GET["action"]=="getMemberFields"){
require_once 'backend/data.php';
$payload = $memberDataFieldsJSON;
} else {
throw new Exception("Action not known");
}
$response["error"] = false;
} catch (Exception $e){
$response["error"] = true;
$response["error_msg"] = $e->getMessage();
$response["error_code"]= $e->getCode();
}
$response["payload"] = isset($payload) ? $payload : null;
exit(json_encode($response));
?>