getGranulesIndex.php
1.3 KB
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
36
37
38
39
40
41
42
43
44
<?php
/**
* @file getGranulesIndex.php
* @brief Returns JSON with URLs of *_times.nc for all DataSets
* @version $Id: $
*/
require_once './DDserverWeb_ini.php';
$alias = array(baseDir => webAlias);
$replace = array("_" => "-");
// $dataSet = strtr($_GET['id'], $replace);
$referXML = baseDir."/DDsys.xml";
$DDsys = new DOMDocument("1.0");
$DDsys->load($referXML);
$VIs = $DDsys->getElementsByTagName("VI");
$main = array();
$index = array();
foreach ( $VIs as $VI )
{
if ($VI->getElementsByTagName("NAME")->item(0)->getAttribute('base') == "LOCAL")
{
$id = $VI->getElementsByTagName("NAME")->item(0)->nodeValue;
$location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue;
$times = $VI->getElementsByTagName("TIMES")->item(0)->nodeValue;
if (!file_exists($location.$times)) continue; // no times info
if (file_exists($location."RestrictedAccess")) continue; // PrivateAccess
$index[strtr($id,$replace)] = substr($location.$times,strlen(baseDir));
}
}
$main[webAlias] = $index;
$json = json_encode($main);
file_put_contents("GRANULES/allDatasets.json", $json);
exit($json);
?>