-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminAPI.php
48 lines (46 loc) · 1.73 KB
/
adminAPI.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
<?php
require('dbHandler.php');
//ADD PIT SCOUT AND LEAD SCOUT TO DOCUMENTATION
/*
Valid POST API Requests:
getConfig - Responds with human readable JSON settings for the site and database.
Response Format:
{'server' : '', 'db' : '', 'username' : '', 'eventcode' : '', 'tbaKey' : '', 'datatable' : '',
'tbatable' : '', 'datatableExists' : '', 'tbatableExists' : '', 'serverExists' : '', 'dbExists' : ''}
writeConfig - Write status and respond with status.
Argument Format:
{'server' : '', 'db' : '', 'username' : '', 'password' : '',
'eventcode' : '', 'tbaKey' : '', 'datatable' : '', 'tbatable' : ''}
Response Format:
{'server' : '', 'db' : '', 'username' : '', 'eventcode' : '', 'tbaKey' : '', 'datatable' : '',
'tbatable' : '', 'datatableExists' : '', 'tbatableExists' : '', 'serverExists' : '', 'dbExists' : ''}
createDB - Tries to create DB and associated tables.
Response Format:
{'server' : '', 'db' : '', 'username' : '', 'eventcode' : '', 'tbaKey' : '', 'datatable' : '',
'tbatable' : '', 'datatableExists' : '', 'tbatableExists' : '', 'serverExists' : '', 'dbExists' : ''}
*/
if (isset($_POST["getConfig"])){
$db = new dbHandler();
echo(json_encode($db->getStatus()));
}
else if (isset($_POST["writeConfig"])){
$db = new dbHandler();
$db->settings->writeDbConfig(json_decode($_POST["writeConfig"]));
$db->refreshSettings();
echo(json_encode($db->getStatus()));
}
else if (isset($_POST["createDB"])){
$db = new dbHandler();
try{
if(! $db->getDatabaseExists()){
$db->createDB();
}
$db->createAllTables();
}
catch (Exception $e){
error_log($e);
}
$db->refreshSettings();
echo(json_encode($db->getStatus()));
}
?>