cleanRemoteParams.php
1.63 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
45
<?php
/*
* Executable to clean up Remote Params
*/
if (!function_exists('__autoload')) {
function __autoload($class_name) {
require_once $class_name . '.php';
}
}
$AMDA_IHM = getenv('AMDA_IHM');
require_once $AMDA_IHM."/php/config.php";
if (file_exists(DATAPATH."/RemoteData/Bases.xml")) {
try {
$client = new SoapClient(DD_WSDL);
}
catch (SoapFault $exception) {
$msg = $exception->faultstring.PHP_EOL;
exit($msg);
}
$basesDom = new DomDocument("1.0");
$basesDom->load(DDSERVICE."/BASE/INFO/Bases.xml"); // Remote from DDBASE/INFO
foreach ($basesDom->getElementsByTagName("dataCenter") as $center) {
$id = $center->getAttribute("xml:id");
if (is_dir(DATAPATH."/RemoteData/$id")) {
foreach (glob(DATAPATH."/RemoteData/$id/*") as $file) {
if (basename($file) == "base.xml") continue;
$ds = basename($file,".nc");
if ($client->isRemoteViAdded($id, strtolower($ds))) continue; // VI exists; do nothing
// vi was deleted in DDBASE; delete everything
unlink($file);
$paramId = strtolower($id)."_".strtolower($ds);
foreach (glob(DATAPATH."/RemoteData/PARAMS/$paramId*.xml") as $xml) unlink($xml);
foreach (glob(DATAPATH."/LocalData/ParamDef/$paramId*.xml") as $xml) unlink($xml);
}
}
}
}
?>