3 * Change the minimum age in the profile
4 * GET http://l2.gamestickservices.net/api/rest/parentcontroll/change/agerating/17/7694f4a66316e53c8cdd9d9954bd611d/view.json;jsessionid=zz
6 header('HTTP/1.0 500 Internal Server Error');
8 $rootDir = dirname(__FILE__, 6);
9 require_once $rootDir . '/config.php';
10 require_once $rootDir . '/src/ProfileDb.php';
12 if (!isset($_GET['jsessionid'])) {
13 header('HTTP/1.0 400 Bad Request');
14 header('Content-Type: text/plain');
15 echo "Session ID missing\n";
18 $sessionId = $_GET['jsessionid'];
20 if (!isset($_GET['age'])) {
21 header('HTTP/1.0 400 Bad Request');
22 header('Content-Type: text/plain');
27 if ($age != 3 && $age != 7 && $age != 12 && $age != 17) {
28 header('HTTP/1.0 400 Bad Request');
29 header('Content-Type: text/plain');
30 echo "Invalid age (only 3, 7, 12 and 17 allowed)\n";
34 if (!isset($_GET['pwhash'])) {
35 header('HTTP/1.0 400 Bad Request');
36 header('Content-Type: text/plain');
37 echo "Password hash missing\n";
40 $passwordHash = $_GET['pwhash'];
41 if (strlen($passwordHash) != 32) {
42 header('HTTP/1.0 400 Bad Request');
43 header('Content-Type: text/plain');
44 echo "Password hash must be 32 characters long\n";
48 $profileDb = new ProfileDb();
49 $profile = $profileDb->getProfileBySessionId($sessionId);
50 if ($profile === null) {
51 header('HTTP/1.0 404 Not Found');
52 header('Content-Type: text/plain');
53 echo "Unknown session ID\n";
57 //we do not verify the actual password
58 // the hash is calculated md5($password)
59 $profileDb->updateProfile(
72 $json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
74 header('HTTP/1.0 200 OK');
75 header('Content-Type: application/json');