diff --git a/php/classes/WebServer.php b/php/classes/WebServer.php index 0bae591..7e4bff3 100644 --- a/php/classes/WebServer.php +++ b/php/classes/WebServer.php @@ -6,8 +6,6 @@ * @version $Id: WebServer.php 2968 2015-06-29 13:17:00Z natacha $ */ -require_once '../config.php'; - class WebResultMgr { private $resDOM; @@ -572,14 +570,6 @@ class WebServer $vars = $res['vars']; - if (!$vars["token"]) { - return array('success' => false, 'message' => "E01\nAuthentication is required for this webservice."); - } - - if($this->getNewToken()['token'] != $vars["token"]) { - return array('success' => false, 'message' => "E02\nToken expired. Please authenticate again."); - } - if ((strtotime($vars["stopTime"]) - strtotime($vars["startTime"])) < 0){ if ($this->isSoap) throw new SoapFault("request01","Start time must be higher than stop time"); else return array('success' => false, 'message' => "Start time must be higher than stop time"); diff --git a/php/rest/auth.php b/php/rest/auth.php index da2f819..1467c40 100644 --- a/php/rest/auth.php +++ b/php/rest/auth.php @@ -1,24 +1,22 @@ - getNewToken($_GET); +$amda_ws = new WebServer(); +$result = $amda_ws->getNewToken($_GET); - if ($result['success']){ - echo $result['token']; - } - else { - echo $result['message']; - } +if ($result['success']) { + echo $result['token']; +} else { + echo $result['message']; +} ?> \ No newline at end of file diff --git a/php/rest/getDatasetData.php b/php/rest/getDatasetData.php index 632587c..1ba4652 100755 --- a/php/rest/getDatasetData.php +++ b/php/rest/getDatasetData.php @@ -1,38 +1,45 @@ getDataset($_GET); - - if ($result['success']){ - $file = str_replace("http://oberoi.cesr.fr/AMDA-WS/",BASE_PATH ,$result['dataFileURLs']); - - if ($file){ +/** + * @file getParameter.php + * @brief REST interface for service getParameter + * + * + * @version $Id: $ + */ +ini_set("allow_url_fopen", true); +require_once '../config.php'; + +$amda_ws = new WebServer(); + +if (!$_GET["token"]) { + return array('success' => false, 'message' => "E01\nAuthentication is required for this webservice."); +} +if ($amda_ws->getNewToken()['token'] != $_GET["token"]) { + return array('success' => false, 'message' => "E02\nToken expired. Please authenticate again."); +} + +$result = $amda_ws->getDataset($_GET); + +if ($result['success']) { + $file = str_replace("http://oberoi.cesr.fr/AMDA-WS/", BASE_PATH, $result['dataFileURLs']); + + if ($file) { // header('Content-type: text/xml'); // $contenu = file_get_contents($file); // error_log($contenu,3,'/home/natacha/TMP/tmp.xml'); // echo $contenu; - -header('Content-type: text/xml'); -$doc = new DOMDocument(); -$doc->load($file); -echo $doc->saveXML(); - - - } - } - else { - $success = "false"; - echo ''; - echo ''.$success.''; - echo ''.$result['message'].''; + + header('Content-type: text/xml'); + $doc = new DOMDocument(); + $doc->load($file); + echo $doc->saveXML(); + + } +} else { + $success = "false"; + echo ''; + echo '' . $success . ''; + echo '' . $result['message'] . ''; +} ?> diff --git a/php/rest/getOrbites.php b/php/rest/getOrbites.php index c0c7408..e11cfc4 100644 --- a/php/rest/getOrbites.php +++ b/php/rest/getOrbites.php @@ -1,23 +1,30 @@ getOrbites($_GET); +require_once '../config.php'; - if ($result['success']){ - echo $result['dataFileURLs']; - } - else { - echo $result['message']; - } +$amda_ws = new WebServer(); + +if (!$_GET["token"]) { + return array('success' => false, 'message' => "E01\nAuthentication is required for this webservice."); +} +if ($amda_ws->getNewToken()['token'] != $_GET["token"]) { + return array('success' => false, 'message' => "E02\nToken expired. Please authenticate again."); +} + +$result = $amda_ws->getOrbites($_GET); + +if ($result['success']) { + echo $result['dataFileURLs']; +} else { + echo $result['message']; +} ?> \ No newline at end of file diff --git a/php/rest/getParameter.php b/php/rest/getParameter.php index fbd86de..05165b4 100644 --- a/php/rest/getParameter.php +++ b/php/rest/getParameter.php @@ -1,23 +1,30 @@ getParameter($_GET); +require_once '../config.php'; - if ($result['success']){ - echo $result['dataFileURLs']; - } - else { - echo $result['message']; - } +$amda_ws = new WebServer(); + +if (!$_GET["token"]) { + return array('success' => false, 'message' => "E01\nAuthentication is required for this webservice."); +} +if ($amda_ws->getNewToken()['token'] != $_GET["token"]) { + return array('success' => false, 'message' => "E02\nToken expired. Please authenticate again."); +} + +$result = $amda_ws->getParameter($_GET); + +if ($result['success']) { + echo $result['dataFileURLs']; +} else { + echo $result['message']; +} ?> \ No newline at end of file -- libgit2 0.21.2