forked from causefx/Organizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
36 lines (36 loc) · 930 Bytes
/
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
<?php
// Include functions
require_once('functions.php');
// Lazyload settings
$databaseConfig = configLazy('config/config.php');
// Get Action
if (isset($_POST['a'])) { $action = $_POST['a']; }
if (isset($_POST['k'])) { $key = $_POST['k']; }
if (isset($_GET['a'])) { $action = $_GET['a']; }
if (isset($_GET['k'])) { $key = $_GET['k']; }
unset($_POST['a']);
unset($_POST['k']);
//Set Default Result
$result = "An error has occurred";
//Check Key
if (!isset($key)) {
exit(json_encode("No API Key set"));
}elseif (strtolower(ORGANIZRAPI) != strtolower($key)) {
exit(json_encode("API Key mismatch"));
}
//Start API Call
if (isset($action)) {
switch ($action) {
case "1":
$result = "test";
break;
case "2":
$result = "other test";
break;
default:
$result = "$action not defined";
}
}
//return JSON array
exit(json_encode($result));
?>