Blame view

src/DDSERVICES/REST/getGranules.php 1.07 KB
2a42aad3   Benjamin Renard   Add getGranules i...
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
32
33
34
35
<?php
  
/** 
*   @file getGranules.php
*   @brief Returns Granules for a given DataSet 
*   @version $Id:  $ 
*/

		if (!isset($_GET['id'])) exit('INPUT ERROR');
		
		require_once './DDserverWeb_ini.php';
		
		error_reporting(E_ERROR | E_WARNING | E_PARSE);

		$replace = array("-" => "_");

		$dataSet = strtr($_GET['id'], $replace);

		$referXML = baseDir."/DDsys.xml";
		$DDsys = new DOMDocument("1.0");
		$DDsys->load($referXML);
		$xp = new domxpath($DDsys);
		$VI = $xp->query("//NAME[.='".$dataSet."']");

		if ($VI->item(0)->nodeValue != NULL)
                {
                        $location = $VI->item(0)->parentNode->getElementsByTagName("LOCATION")->item(0)->nodeValue;
                        $times = $VI->item(0)->parentNode->getElementsByTagName("TIMES")->item(0)->nodeValue;
                        $cmd = "/opt/tools/DDServer/bin/GetGranules ".$location." ".$times;
                        exec($cmd, $output, $result_code);
                        if ($result_code === 0)
                                exit(implode("\n",$output));
                }
		exit('ERROR');
?>