Commit 5e2ea05e36e0e156aac5ec5a4bfcfa9c2f3e1f86
1 parent
1922ad04
Exists in
master
and in
110 other branches
update REST
Showing
5 changed files
with
66 additions
and
58 deletions
Show diff stats
php/classes/WebServer.php
... | ... | @@ -301,9 +301,9 @@ class WebServer |
301 | 301 | */ |
302 | 302 | public function getNewToken() |
303 | 303 | { |
304 | - $timeStamp = (new DateTime())->getTimestamp(); | |
305 | 304 | // generate token from timeStamp and some salt |
306 | - $newToken = md5(1321 * (int)($timeStamp / timeLimitQuery)); | |
305 | + $newToken = md5(1321 * (int)( time() / WSConfigClass::$timeLimitQuery)); | |
306 | + | |
307 | 307 | return array('success' => true, 'token' => $newToken); |
308 | 308 | } |
309 | 309 | ... | ... |
php/rest/getDataset.php
... | ... | @@ -5,17 +5,23 @@ |
5 | 5 | */ |
6 | 6 | |
7 | 7 | //ini_set("allow_url_fopen", true); |
8 | -require_once '../config.php'; | |
8 | + require_once '../config.php'; | |
9 | 9 | |
10 | -$amda_ws = new WebServer(); | |
10 | + if (!key_exists("token", $_GET)) | |
11 | + { | |
12 | + $result = array('success' => false, 'message' => "Authentication is required for this webservice."); | |
13 | + exit(json_encode($result)); | |
14 | + } | |
11 | 15 | |
12 | -if (!key_exists("token", $_GET)) { | |
13 | - $result = array('success' => false, 'message' => "Authentication is required for this webservice."); | |
14 | -} else if ($amda_ws->getNewToken()['token'] != $_GET["token"]) { | |
15 | - $result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again."); | |
16 | -} else { | |
17 | - $result = $amda_ws->getDataset($_GET); | |
18 | -} | |
16 | + $amda_ws = new WebServer(); | |
17 | + | |
18 | + if ($amda_ws->getNewToken()['token'] != $_GET["token"]) | |
19 | + { | |
20 | + $result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again."); | |
21 | + } else | |
22 | + { | |
23 | + $result = $amda_ws->getDataset($_GET); | |
24 | + } | |
19 | 25 | |
20 | -echo json_encode($result); | |
21 | -?> | |
26 | + echo json_encode($result); | |
27 | + ?> | ... | ... |
php/rest/getOrbites.php
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** |
4 | - * @file getParameter.php | |
5 | - * @brief REST interface for service getParameter | |
6 | - * | |
7 | - * | |
8 | - * @version $Id: $ | |
4 | + * @file getOrbites.php | |
5 | + * @brief REST interface for service getOrbites | |
9 | 6 | */ |
10 | 7 | |
11 | -require_once '../config.php'; | |
8 | + require_once '../config.php'; | |
12 | 9 | |
13 | -$amda_ws = new WebServer(); | |
10 | + if (!key_exists("token", $_GET)) | |
11 | + { | |
12 | + $result = array('success' => false, 'message' => "Authentication is required for this webservice."); | |
13 | + exit(json_encode($result)); | |
14 | + } | |
15 | + | |
16 | + $amda_ws = new WebServer(); | |
17 | + | |
18 | + if ($amda_ws->getNewToken()['token'] != $_GET["token"]) | |
19 | + { | |
20 | + $result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again."); | |
21 | + } else | |
22 | + { | |
23 | + $result = $amda_ws->getOrbites($_GET); | |
24 | + } | |
14 | 25 | |
15 | -if (!key_exists("token", $_GET)) { | |
16 | - $result = array('success' => false, 'message' => "E01: Authentication is required for this webservice."); | |
17 | -} else if ($amda_ws->getNewToken()['token'] != $_GET["token"]) { | |
18 | - $result = array('success' => false, 'message' => "E02: Token expired. Please authenticate again."); | |
19 | -} else { | |
20 | - $result = $amda_ws->getOrbites($_GET); | |
21 | -} | |
22 | - | |
23 | -if ($result['success']) { | |
24 | - echo $result['dataFileURLs']; | |
25 | -} else { | |
26 | - echo $result['message']; | |
27 | -} | |
26 | + echo json_encode($result); | |
28 | 27 | |
29 | 28 | ?> |
30 | 29 | \ No newline at end of file | ... | ... |
php/rest/getParameter.php
... | ... | @@ -3,21 +3,25 @@ |
3 | 3 | /** |
4 | 4 | * @file getParameter.php |
5 | 5 | * @brief REST interface for service getParameter |
6 | - * | |
7 | - * | |
8 | - * @version $Id: $ | |
9 | 6 | */ |
10 | 7 | |
11 | -require_once '../config.php'; | |
8 | + require_once '../config.php'; | |
12 | 9 | |
13 | -$amda_ws = new WebServer(); | |
10 | + if (!key_exists("token", $_GET)) | |
11 | + { | |
12 | + $result = array('success' => false, 'message' => "Authentication is required for this webservice."); | |
13 | + exit(json_encode($result)); | |
14 | + } | |
15 | + | |
16 | + $amda_ws = new WebServer(); | |
14 | 17 | |
15 | -if (!key_exists("token", $_GET)) { | |
16 | - $result = array('success' => false, 'message' => "Authentication is required for this webservice."); | |
17 | -} else if ($amda_ws->getNewToken()['token'] != $_GET["token"]) { | |
18 | - $result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again."); | |
19 | -} else { | |
20 | - $result = $amda_ws->getParameter($_GET); | |
21 | -} | |
22 | -echo json_encode($result); | |
18 | + if ($amda_ws->getNewToken()['token'] != $_GET["token"]) | |
19 | + { | |
20 | + $result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again."); | |
21 | + } else | |
22 | + { | |
23 | + $result = $amda_ws->getParameter($_GET); | |
24 | + } | |
25 | + | |
26 | + echo json_encode($result); | |
23 | 27 | ?> |
24 | 28 | \ No newline at end of file | ... | ... |
php/rest/getTimeTablesList.php
... | ... | @@ -3,23 +3,22 @@ |
3 | 3 | /** |
4 | 4 | * @file getTimeTablesList.php |
5 | 5 | * @brief REST interface for service getTimeTablesList |
6 | -* | |
7 | -* | |
8 | -* @version $Id: $ | |
9 | 6 | */ |
10 | 7 | |
11 | - require_once '../config.php'; | |
8 | + require_once '../config.php'; | |
12 | 9 | |
13 | - $amda_ws = new WebServer(); | |
10 | + $amda_ws = new WebServer(); | |
14 | 11 | |
15 | - $result = $amda_ws->getTimeTablesList($_GET); | |
12 | + $result = $amda_ws->getTimeTablesList($_GET); | |
16 | 13 | |
17 | - if ($result['success']){ | |
18 | - echo $result['TimeTablesList']; | |
19 | - } | |
20 | - else { | |
21 | - echo $result['message']; | |
22 | - } | |
14 | + if ($result['success']) | |
15 | + { | |
16 | + echo $result['TimeTablesList']; | |
17 | + } | |
18 | + else | |
19 | + { | |
20 | + echo $result['message']; | |
21 | + } | |
23 | 22 | ?> |
24 | 23 | |
25 | 24 | ... | ... |