getSwStop.php
1.32 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
<?php
if ($argv[1] == '') exit('ERROR');
$DDBASE = getenv('DDBASE');
if ($DDBASE == '') exit('ERROR');
switch ($argv[1]) {
case 'OMNI':
$file = $DDBASE.'/OMNI/HOUR/SWStop';
if (!file_exists($file)) exit('ERROR');
$timeArray = file($file);
$timeValue = trim($timeArray[0]).'.000Z';
break;
case 'ACE_RealTime' :
$fileMAG = $DDBASE.'/ACE/RealTime/MAG/mag_info.xml';
$fileSW = $DDBASE.'/ACE/RealTime/SWEPAM/swepam_info.xml';
if (!file_exists($fileMAG) || !file_exists($fileSW)) exit('ERROR');
$xml = new DomDocument('1.0');
if (!$xml->load($fileMAG)) exit('ERROR');
$timeMAG = $xml->getElementsByTagName('GlobalStop');
if ($timeMAG->length == 0) exit('ERROR');
$timeMagValue = $timeMAG->item(0)->nodeValue;
if (!$xml->load($fileSW)) exit('ERROR');
$timeSW = $xml->getElementsByTagName('GlobalStop');
if ($timeSW->length == 0) exit('ERROR');
$timeSwValue = $timeSW->item(0)->nodeValue;
$timeValue = $timeSwValue > $timeMagValue ? $timeSwValue : $timeMagValue;
break;
}
exit($timeValue);
?>