-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaskHint.php
31 lines (22 loc) · 978 Bytes
/
askHint.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
<?php
require_once "shared/connect.php";
require_once "shared/TokenGenerator.php";
require_once "shared/common.inc.php";
$request = json_decode(file_get_contents('php://input'),true);
header('Content-Type: application/json');
if ((!isset($request['sToken']) && !$config->testMode->active) || !isset($request['sPlatform'])) {
echo json_encode(array('bSuccess' => false, 'sError' => 'missing sToken or sPlatform POST variable.'));
exit;
}
$params = getPlatformTokenParams($request['sToken'], $request['sPlatform'], $request['taskId'], $db);
$newParams = [
'itemUrl' => $params['itemUrl'],
'idUser' => $params['idUser'],
'askedHint' => intval($params['nbHintsGiven'])+1
];
if(isset($params['idItem'])) {
$newParams['idItem'] = $params['idItem'];
}
$tokenGenerator = new TokenGenerator($config->platform->private_key, $config->platform->name, null);
$jws = $tokenGenerator->encodeJWS($newParams);
echo json_encode(['success' => 'true', 'hintToken' => $jws]);