Commit 334555a815bb9fba08ad2bce17d9d6ec933567fc
Exists in
master
and in
104 other branches
Merge branch 'webservices' into 'master'
Webservices See merge request !38
Showing
4 changed files
with
95 additions
and
39 deletions
Show diff stats
php/WebServices/WebServer.php
@@ -286,17 +286,6 @@ class WebServer | @@ -286,17 +286,6 @@ class WebServer | ||
286 | $this->throwError("deleteProcessError", $e->getMessage()); | 286 | $this->throwError("deleteProcessError", $e->getMessage()); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | - | ||
290 | -/* | ||
291 | -* generate AUTH token for access to REST services | ||
292 | -*/ | ||
293 | - public function getNewToken() | ||
294 | - { | ||
295 | - // generate token from timeStamp and some salt | ||
296 | - $newToken = md5(1321 * (int)( time() / WSConfigClass::$timeLimitQuery)); | ||
297 | - | ||
298 | - return array('success' => true, 'token' => $newToken); | ||
299 | - } | ||
300 | 289 | ||
301 | private function excludePrivateNodes($locParamSrc, $locParamDst) | 290 | private function excludePrivateNodes($locParamSrc, $locParamDst) |
302 | { | 291 | { |
@@ -325,8 +314,24 @@ class WebServer | @@ -325,8 +314,24 @@ class WebServer | ||
325 | $this->throwError('workspaceError', 'Cannot save Amda Local DataBase Parameters description file'.$this->userID); | 314 | $this->throwError('workspaceError', 'Cannot save Amda Local DataBase Parameters description file'.$this->userID); |
326 | } | 315 | } |
327 | 316 | ||
317 | + private function checkInputTime($startTime, $stopTime) | ||
318 | + { | ||
319 | + if ($stopTime <= $startTime ) | ||
320 | + $this->throwError("requestError", "Requested time interval should be greater than 0"); | ||
321 | + } | ||
322 | + | ||
328 | /************************** WEB SERVICES **************************************/ | 323 | /************************** WEB SERVICES **************************************/ |
329 | - | 324 | +/* |
325 | +* generate AUTH token for access to REST services | ||
326 | +*/ | ||
327 | + public function getNewToken() | ||
328 | + { | ||
329 | + // generate token from timeStamp and some salt | ||
330 | + $newToken = md5(1321 * (int)( time() / WSConfigClass::$timeLimitQuery)); | ||
331 | + | ||
332 | + return array('success' => true, 'token' => $newToken); | ||
333 | + } | ||
334 | + | ||
330 | /* | 335 | /* |
331 | * public data only : user impex | 336 | * public data only : user impex |
332 | */ | 337 | */ |
@@ -390,18 +395,25 @@ class WebServer | @@ -390,18 +395,25 @@ class WebServer | ||
390 | $this->initUserMgr(); | 395 | $this->initUserMgr(); |
391 | 396 | ||
392 | $vars = $res['vars']; | 397 | $vars = $res['vars']; |
393 | - | ||
394 | - if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ | ||
395 | - $this->throwError("requestError", "Requested time interval should be greater than 0"); | 398 | + |
399 | + if (is_numeric($vars["startTime"])) { | ||
400 | + $this->checkInputTime($vars["startTime"],$vars["stopTime"]); | ||
401 | + $vars["startTime"] = date("Y-m-d\TH:i:s", $vars["startTime"]); | ||
402 | + $vars["stopTime"] = date("Y-m-d\TH:i:s", $vars["stopTime"]); | ||
403 | + } | ||
404 | + else { | ||
405 | + $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); | ||
396 | } | 406 | } |
397 | 407 | ||
398 | - $paramId = array(); | ||
399 | - array_push($paramId, $vars["parameterID"]); | ||
400 | - | ||
401 | - if (!$vars["timeFormat"]) | 408 | + if (!$vars["timeFormat"]) { |
402 | $timeFormat = "ISO8601"; | 409 | $timeFormat = "ISO8601"; |
403 | - else | 410 | + } |
411 | + else { | ||
404 | $timeFormat = $vars["timeFormat"]; | 412 | $timeFormat = $vars["timeFormat"]; |
413 | + } | ||
414 | + | ||
415 | + $paramId = array(); | ||
416 | + array_push($paramId, $vars["parameterID"]); | ||
405 | 417 | ||
406 | if (!$vars["gzip"]) | 418 | if (!$vars["gzip"]) |
407 | $gzip = 0; | 419 | $gzip = 0; |
@@ -465,11 +477,23 @@ class WebServer | @@ -465,11 +477,23 @@ class WebServer | ||
465 | $this->initUserMgr(); | 477 | $this->initUserMgr(); |
466 | 478 | ||
467 | $vars = $res['vars']; | 479 | $vars = $res['vars']; |
468 | - | ||
469 | - if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ | ||
470 | - $this->throwError("requestError", "Requested time interval should be greater than 0"); | ||
471 | - } | ||
472 | 480 | ||
481 | + if (is_numeric($vars["startTime"])) { | ||
482 | + $this->checkInputTime($vars["startTime"],$vars["stopTime"]); | ||
483 | + $vars["startTime"] = date("Y-m-d\TH:i:s", $vars["startTime"]); | ||
484 | + $vars["stopTime"] = date("Y-m-d\TH:i:s", $vars["stopTime"]); | ||
485 | + } | ||
486 | + else { | ||
487 | + $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); | ||
488 | + } | ||
489 | + | ||
490 | + if (!$vars["timeFormat"]) { | ||
491 | + $timeFormat = "ISO8601"; | ||
492 | + } | ||
493 | + else { | ||
494 | + $timeFormat = $vars["timeFormat"]; | ||
495 | + } | ||
496 | + | ||
473 | $dataSetDom = $this->getDatasetInfo($vars['datasetID']); | 497 | $dataSetDom = $this->getDatasetInfo($vars['datasetID']); |
474 | 498 | ||
475 | $params = $dataSetDom->getElementsByTagName("parameter"); | 499 | $params = $dataSetDom->getElementsByTagName("parameter"); |
@@ -506,11 +530,6 @@ class WebServer | @@ -506,11 +530,6 @@ class WebServer | ||
506 | $sampling = $vars["sampling"]; | 530 | $sampling = $vars["sampling"]; |
507 | } | 531 | } |
508 | 532 | ||
509 | - if (!$vars["timeFormat"]) | ||
510 | - $timeFormat = "ISO8601"; | ||
511 | - else | ||
512 | - $timeFormat = $vars["timeFormat"]; | ||
513 | - | ||
514 | if (!$vars["gzip"]) | 533 | if (!$vars["gzip"]) |
515 | $gzip = 0; | 534 | $gzip = 0; |
516 | else | 535 | else |
@@ -642,11 +661,23 @@ class WebServer | @@ -642,11 +661,23 @@ class WebServer | ||
642 | $this->initUserMgr(); | 661 | $this->initUserMgr(); |
643 | 662 | ||
644 | $vars = $res['vars']; | 663 | $vars = $res['vars']; |
645 | - | ||
646 | - if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){ | ||
647 | - $this->throwError("requestError", "Requested time interval should be greater than 0"); | 664 | + |
665 | + if (is_numeric($vars["startTime"])) { | ||
666 | + $this->checkInputTime($vars["startTime"],$vars["stopTime"]); | ||
667 | + $vars["startTime"] = date("Y-m-d\TH:i:s", $vars["startTime"]); | ||
668 | + $vars["stopTime"] = date("Y-m-d\TH:i:s", $vars["stopTime"]); | ||
669 | + } | ||
670 | + else { | ||
671 | + $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); | ||
672 | + } | ||
673 | + | ||
674 | + if (!$vars["timeFormat"]) { | ||
675 | + $timeFormat = "ISO8601"; | ||
676 | + } | ||
677 | + else { | ||
678 | + $timeFormat = $vars["timeFormat"]; | ||
648 | } | 679 | } |
649 | - | 680 | + |
650 | $spacecraft = $vars["spacecraft"]; | 681 | $spacecraft = $vars["spacecraft"]; |
651 | $coordinateSystem = $vars["coordinateSystem"]; | 682 | $coordinateSystem = $vars["coordinateSystem"]; |
652 | 683 | ||
@@ -667,11 +698,6 @@ class WebServer | @@ -667,11 +698,6 @@ class WebServer | ||
667 | $paramId = array(); | 698 | $paramId = array(); |
668 | array_push($paramId, $orbitParam['parameterID']); | 699 | array_push($paramId, $orbitParam['parameterID']); |
669 | 700 | ||
670 | - if (!$vars["timeFormat"]) | ||
671 | - $timeFormat = "ISO8601"; | ||
672 | - else | ||
673 | - $timeFormat = $vars["timeFormat"]; | ||
674 | - | ||
675 | if (!$vars["gzip"]) | 701 | if (!$vars["gzip"]) |
676 | $gzip = 0; | 702 | $gzip = 0; |
677 | else | 703 | else |
@@ -705,6 +731,15 @@ class WebServer | @@ -705,6 +731,15 @@ class WebServer | ||
705 | $vars = $res['vars']; | 731 | $vars = $res['vars']; |
706 | $mission = $vars["missionID"]; | 732 | $mission = $vars["missionID"]; |
707 | 733 | ||
734 | + if (is_numeric($vars["startTime"])) { | ||
735 | + $this->checkInputTime($vars["startTime"],$vars["stopTime"]); | ||
736 | + $vars["startTime"] = date("Y-m-d\TH:i:s", $vars["startTime"]); | ||
737 | + $vars["stopTime"] = date("Y-m-d\TH:i:s", $vars["stopTime"]); | ||
738 | + } | ||
739 | + else { | ||
740 | + $this->checkInputTime(strtotime($vars["startTime"]),strtotime($vars["stopTime"])); | ||
741 | + } | ||
742 | + | ||
708 | $resultFilePrefix = strtolower(__FUNCTION__)."_".$mission."_".date("YmdHms",strtotime($vars["startTime"]))."_".date("YmdHms",strtotime($vars["stopTime"])); | 743 | $resultFilePrefix = strtolower(__FUNCTION__)."_".$mission."_".date("YmdHms",strtotime($vars["startTime"]))."_".date("YmdHms",strtotime($vars["stopTime"])); |
709 | 744 | ||
710 | if ($this->userID != "impex") | 745 | if ($this->userID != "impex") |
php/rest/getDataset.php
@@ -41,7 +41,14 @@ | @@ -41,7 +41,14 @@ | ||
41 | $result = array('success' => false, 'message' => "Authentication is required for this webservice."); | 41 | $result = array('success' => false, 'message' => "Authentication is required for this webservice."); |
42 | exit(json_encode($result)); | 42 | exit(json_encode($result)); |
43 | } | 43 | } |
44 | - | 44 | + |
45 | + if ($_GET['startTime'] && strpos($_GET['startTime'], ' ') !== false) | ||
46 | + { | ||
47 | + $result = array('success' => false, | ||
48 | + 'message' => "Check that there is no + (plus) character in your time definition. + is a special character and should be encoded by %2B"); | ||
49 | + exit(json_encode($result)); | ||
50 | + } | ||
51 | + | ||
45 | $amda_ws = new WebServer(); | 52 | $amda_ws = new WebServer(); |
46 | 53 | ||
47 | if ($amda_ws->getNewToken()['token'] != $_GET["token"]) | 54 | if ($amda_ws->getNewToken()['token'] != $_GET["token"]) |
php/rest/getOrbites.php
@@ -52,6 +52,13 @@ | @@ -52,6 +52,13 @@ | ||
52 | exit(json_encode($result)); | 52 | exit(json_encode($result)); |
53 | } | 53 | } |
54 | 54 | ||
55 | + if ($_GET['startTime'] && strpos($_GET['startTime'], ' ') !== false) | ||
56 | + { | ||
57 | + $result = array('success' => false, | ||
58 | + 'message' => "Check that there is no + (plus) character in your time definition. + is a special character and should be encoded by %2B"); | ||
59 | + exit(json_encode($result)); | ||
60 | + } | ||
61 | + | ||
55 | $amda_ws = new WebServer(); | 62 | $amda_ws = new WebServer(); |
56 | 63 | ||
57 | if ($amda_ws->getNewToken()['token'] != $_GET["token"]) | 64 | if ($amda_ws->getNewToken()['token'] != $_GET["token"]) |
php/rest/getParameter.php
@@ -42,6 +42,13 @@ | @@ -42,6 +42,13 @@ | ||
42 | $result = array('success' => false, 'message' => "Authentication is required for this webservice."); | 42 | $result = array('success' => false, 'message' => "Authentication is required for this webservice."); |
43 | exit(json_encode($result)); | 43 | exit(json_encode($result)); |
44 | } | 44 | } |
45 | + | ||
46 | + if ($_GET['startTime'] && strpos($_GET['startTime'], ' ') !== false) | ||
47 | + { | ||
48 | + $result = array('success' => false, | ||
49 | + 'message' => "Check that there is no + (plus) character in your time definition. + is a special character and should be encoded by %2B"); | ||
50 | + exit(json_encode($result)); | ||
51 | + } | ||
45 | 52 | ||
46 | $amda_ws = new WebServer(); | 53 | $amda_ws = new WebServer(); |
47 | 54 |