-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
135 lines (130 loc) · 5.84 KB
/
index.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
* Created by PhpStorm.
* User: rulxphilome.alexis
* Date: 12/5/2018
* Time: 11:27 AM
*/
ini_set('display_errors', 1);
require_once './ODKAggragateDataExtract.php';
require_once './ODKAggregateForm.php';
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8",true);
if(isset($_POST['action'])){
ini_set('max_execution_time', 300);
switch ($_POST['action']){
case 'get_form_list': {
//remoteSVR
//username
//password
if(isset($_POST['remoteSVR']) AND isset($_POST['username']) AND isset($_POST['password'])){
$odkLink = new ODKAggragateDataExtract($_POST['remoteSVR'],$_POST['username'],$_POST['password']);
$listOfForms = $odkLink->getFormsList();
unset($odkLink);
echo $listOfForms;
}else{
echo "Can't find the required parameter to retrive List of forms";
}
break;
}
case 'get_form_definition':{
//remoteSVR
//username
//password
//formID
//name
//majorMinorVersion
//version
//hash
//downloadUrl
if(isset($_POST['remoteSVR']) AND isset($_POST['username']) AND isset($_POST['password']) AND isset($_POST['formID']) AND isset($_POST['name']) AND isset($_POST['majorMinorVersion']) AND isset($_POST['version']) AND isset($_POST['password']) AND isset($_POST['hash'])){
$odkLink = new ODKAggragateDataExtract($_POST['remoteSVR'],$_POST['username'],$_POST['password']);
$formsInfo = new ODKAggregateForm($_POST['formID'],$_POST['name'],$_POST['majorMinorVersion'],$_POST['version'],$_POST['hash'],$_POST['downloadUrl']);
$formMSG = $odkLink->getFormDefinitionToJSON($formsInfo);
unset($odkLink);
unset($formsInfo);
echo $formMSG;
}else{
echo "Can't find the required parameter to retrive the form's definition";
}
break;
}
case 'get_form_ids_list':{
//remoteSVR
//username
//password
//formID
//name
//majorMinorVersion
//version
//hash
//downloadUrl
if(isset($_POST['remoteSVR']) AND isset($_POST['username']) AND isset($_POST['password']) AND isset($_POST['formID']) AND isset($_POST['name']) AND isset($_POST['majorMinorVersion']) AND isset($_POST['version']) AND isset($_POST['password']) AND isset($_POST['hash'])){
$odkLink = new ODKAggragateDataExtract($_POST['remoteSVR'],$_POST['username'],$_POST['password']);
$formsIdsList = new ODKAggregateForm($_POST['formID'],$_POST['name'],$_POST['majorMinorVersion'],$_POST['version'],$_POST['hash'],$_POST['downloadUrl']);
$formsIDs = $odkLink->getFormIdList($formsIdsList);
unset($odkLink);
unset($formsIdsList);
echo $formsIDs;
}else{
echo "Can't find the required parameter to retrive the form's ids list";
}
break;
}
case 'get_form_data_for_one_id': {
//remoteSVR
//username
//password
//formID
//name
//majorMinorVersion
//version
//hash
//downloadUrl
//uiid
if(isset($_POST['remoteSVR']) AND isset($_POST['username']) AND isset($_POST['password']) AND isset($_POST['formID']) AND isset($_POST['name']) AND isset($_POST['majorMinorVersion']) AND isset($_POST['version']) AND isset($_POST['password']) AND isset($_POST['hash']) AND isset($_POST['uuid'])){
$odkLink = new ODKAggragateDataExtract($_POST['remoteSVR'],$_POST['username'],$_POST['password']);
$formsInfo = new ODKAggregateForm($_POST['formID'],$_POST['name'],$_POST['majorMinorVersion'],$_POST['version'],$_POST['hash'],$_POST['downloadUrl']);
$formMSG = $odkLink->getFormInstanceValueToJSON($formsInfo,$_POST['uuid']);
unset($odkLink);
unset($formsInfo);
echo $formMSG;
}else{
echo "Can't find the required parameter to retrive the form's definition in get_form_data_for_one_id";
}
break;
}
case 'get_all_data_for_form': {
//remoteSVR
//username
//password
//formID
//name
//majorMinorVersion
//version
//hash
//downloadUrl
//uiid
if(isset($_POST['remoteSVR']) AND isset($_POST['username']) AND isset($_POST['password']) AND isset($_POST['formID']) AND isset($_POST['name']) AND isset($_POST['majorMinorVersion']) AND isset($_POST['version']) AND isset($_POST['password']) AND isset($_POST['hash'])){
$odkLink = new ODKAggragateDataExtract($_POST['remoteSVR'],$_POST['username'],$_POST['password']);
$formsInfo = new ODKAggregateForm($_POST['formID'],$_POST['name'],$_POST['majorMinorVersion'],$_POST['version'],$_POST['hash'],$_POST['downloadUrl']);
$formMSG = $odkLink->getAllFormDataToJSON($formsInfo);
unset($odkLink);
unset($formsInfo);
echo $formMSG;
}else{
echo "Can't find the required parameter to retrive the form's definition in get_form_data_for_one_id";
}
break;
}
default :{
return json_encode(array(
'msg' => 'default behavior'
));
break;
}
}
ini_set('max_execution_time', 30);
}else{
echo "No action defined! Remember this extractor only accept POST request";
}