SPEASYClientClass.php
1.65 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @class SPEASY_CDAWEB
* @brief
*/
class SPEASYClientClass
{
protected $baseId = "";
function __construct()
{
echo '[ERROR] SPEASYClientClass cannot be used directly'.PHP_EOL;
date_default_timezone_set('UTC');
}
public function monitor()
{
if (!defined('SPEASY_PROXY_DATA')) {
echo '[ERROR] Missing SPEASY_PROXY_DATA in config'.PHP_EOL;
return FALSE;
}
if (!file_exists(SPEASY_PROXY_DATA.$this->baseID."/base.xml")) {
echo '[ERROR] Cannot retrieve Speasy base definition for '.$this->baseID." - ".SPEASY_PROXY_DATA.PHP_EOL;
return FALSE;
}
return TRUE;
}
// make components description from base.xml
public function makeCenterNode($xmlDom)
{
$dom = new DOMDocument('1.0', 'utf-8');
$dom->formatOutput = TRUE;
$dom->preserveWhiteSpace = FALSE;
$node = NULL;
if ($dom->load(SPEASY_PROXY_DATA.$this->baseID."/base.xml")) {
$nodeBase = $dom->getElementsByTagName('dataCenter')->item(0);
$node = $xmlDom->importNode($nodeBase, true);
}
return $node;
}
public function makeProxy()
{
$dom = new DOMDocument('1.0', 'utf-8');
$dom->formatOutput = TRUE;
$dom->preserveWhiteSpace = FALSE;
$node = NULL;
if ($dom->load(SPEASY_PROXY_DATA.$this->baseID."/base.xml")) {
if (!is_dir(RemoteData.$this->baseID))
mkdir(RemoteData.$this->baseID, 0775, true);
chmod(RemoteData.$this->baseID,0775);
$dom->save(RemoteData.$this->baseID.'/base.xml');
}
}
}
?>