forked from causefx/Organizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
60 lines (59 loc) · 1.76 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
// Include functions
require_once('user.php');
$USER = new User('registration_callback');
// Get Action
if (isset($_POST['a'])) { $action = $_POST['a']; }
if (isset($_POST['k'])) { $key = $_POST['k']; }
if (isset($_POST['v'])) { $values = $_POST['v']; }
if (isset($_GET['a'])) { $action = $_GET['a']; }
if (isset($_GET['k'])) { $key = $_GET['k']; }
if (isset($_GET['v'])) { $values = explode('|',$_GET['v']); }
unset($_POST['a']);
unset($_POST['k']);
unset($_POST['v']);
//Check Key
if (!isset($key)) {
$result['error'] = "No API Key Set";
exit(json_encode($result));
}elseif (strtolower(ORGANIZRAPI) != strtolower($key)) {
$result['error'] = "API Key mismatch";
exit(json_encode($result));
}
//Start API Call
if (isset($action)) {
switch ($action) {
case "invite-user":
if($values){
if(count($values) == 2){
$user = null;
$email = $values[0];
$server = $values[1];
}else{
$user = $values[0];
$email = $values[1];
$server = $values[2];
}
$USER->invite_user("chris", "[email protected]", "plex");
$result['data'] = "User has been invited";
//$result['data'] = "user = $user | email = $email | server = $server";
}else{
$result['error'] = "No Values Were Set For Function";
}
break;
case "2":
$result = "other test";
break;
default:
$result = "$action Not Defined As API Function";
}
}else{
$result['error'] = "No API Action Set";
}
//Set Default Result
if(!$result){
$result['error'] = "An error has occurred";
}
//return JSON array
exit(json_encode($result));
?>