-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebhooks.php
More file actions
66 lines (55 loc) · 2.76 KB
/
webhooks.php
File metadata and controls
66 lines (55 loc) · 2.76 KB
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
61
62
63
64
65
66
<?php
include_once('lib/AuthenticationHandler.php');
do_authenticate();
header('Content-type: application/json');
$data = json_decode(file_get_contents("php://input"));
if (isset($data))
{
if (isset($data->fn) && isset($data->entityName))
{
require('bootstrap.php');
$json = "{}";
$entity = "";
$message = "";
switch ($data->fn) {
case 'GET':
try { $entity = getEntity($data, $entityManager); } catch(Exception $e) {$message = $e->getMessage();};
$logdata = array('from' => "curl", 'to' => "webhook", 'value' => $message, 'data' => $entity, 'direction' => LogTypes::DIRECTION_INCOMING, 'type' => LogTypes::TYPE_GET_PARTY);
break;
case 'POST':
switch($data->entityName) {
case 'Party':
try { $entity = addEditParty($data, $entityManager); } catch(Exception $e) {$message = $e->getMessage();};
$logdata = array('from' => "curl", 'to' => "webhook", 'value' => $message, 'data' => $entity, 'direction' => LogTypes::DIRECTION_INCOMING, 'type' => LogTypes::TYPE_POST_PARTY);
break;
case 'User':
try { $entity = addEditUser($data, $entityManager); } catch(Exception $e) {$message = $e->getMessage();};
$logdata = array('from' => "curl", 'to' => "webhook", 'value' => $message, 'data' => $entity, 'direction' => LogTypes::DIRECTION_INCOMING, 'type' => LogTypes::TYPE_POST_USER);
break;
case 'Hunt':
try { $entity = addEditHunt($data, $entityManager); } catch(Exception $e) {$message = $e->getMessage();};
$logdata = array('from' => "curl", 'to' => "webhook", 'value' => $message, 'data' => $entity, 'direction' => LogTypes::DIRECTION_INCOMING, 'type' => LogTypes::TYPE_POST_HUNT);
break;
default:
exit(0);
break;
}
break;
case 'DELETE':
try { $entity = deleteEntity($data, $entityManager); } catch(Exception $e) {$message = $e->getMessage();};
$logdata = array('from' => "curl", 'to' => "webhook", 'value' => "Kick user", 'data' => $entity, 'direction' => LogTypes::DIRECTION_INCOMING, 'type' => LogTypes::TYPE_DELETE_USER);
break;
default:
exit(0);
break;
}
$user = null;
if (isset($_SERVER['PHP_AUTH_USER']))
{
$user = $_SERVER['PHP_AUTH_USER'];
}
$json = json_encode(LogMessage($logdata, $entityManager, null, null)->jsonSerialize());
echo $json;
}
}
?>