require_once 'http_request.php'; require_once 'Userdata.php'; $http_request = new http_request(); $request = json_decode($http_request->body, true); $userdata = new Userdata($request); if ($userdata->getUserId() === false) { header("HTTP/1.1 403 Forbidden"); header("Content-Type: text/html"); $data = array('error' => 'Invalid credentials'); echo json_encode($data); exit; } $ok = false; if (strlen($request['cmd']) && strlen($request['username'])) { if (strcmp($request['cmd'], 'savePreferences') == 0) { if (!$userdata->userExists($request['username'])) { header("HTTP/1.1 403 Forbidden"); header("Content-Type: text/html"); print "User does not exist\r\n"; exit; } else { $res = $userdata->savePreferences($request['username'], $request['data']); if ($res) { header("HTTP/1.1 200 OK"); header("Content-Type: text/html"); echo json_encode($data); exit; } } } else { if (strcmp($request['cmd'], 'loadPreferences') == 0) {