SPEASYClientClass.php 1.65 KB
<?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');
        }
    }
   
}
?>