-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
53 lines (43 loc) · 1.1 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
<?php
session_start();
include_once 'server.php';
require __DIR__ . '/vendor/autoload.php';
if (php_sapi_name() == "cli") {
parse_str($argv[1], $_POST);
}
if (isset($_POST["data"])) {
$data = $_POST["data"];
// fix data
$data = preg_replace('/[[:space:]]/', '+', $data);
$server = new Server;
// Unencrypt Data
$cryptor = new \RNCryptor\RNCryptor\Decryptor;
$plaindata = $cryptor->decrypt($data, $server->config->serverHashPassword);
$json = json_decode($plaindata, true);
if (isset($json["task"]) && !empty($json["task"])) {
$task = $json["task"];
switch ($task) {
case "register":
$server->register($json);
break;
case "login":
$server->login($json);
break;
case "saveSurvey":
$server->saveSurvey($json);
break;
case "saveLocation":
$server->saveLocation($json);
break;
case "getNameAndEmail":
$server->getNameAndEmail($json);
break;
default:
$server->printError("{\"errors\":[\"Malformed Server Request\"]");
break;
}
}
} else {
echo "{\"errors\": [\"no data\"]}";
}
?>