makeProxy.php 1.55 KB
<?php
/*
*  Executable to make 'base.xml' proxies for Remote Centers (DD Server)
*/
	error_reporting(E_ERROR);
	
	if (!function_exists('__autoload')) {
		function __autoload($class_name) {
					require_once $class_name . '.php';
		}
	}

   putenv("LD_LIBRARY_PATH=".getenv("LD_LIBRARY_PATH"));
	putenv("PATH=./:".getenv("DDBASEBIN").":/bin:/usr/bin");
	set_include_path("./:".getenv("DATAMANAGER").":".getenv("REMOTEDATA").":".getenv("CALLEXT")); 
	
	$LOGDIR = getenv("DDBASE")."/../LOG";
	if (!is_dir($LOGDIR))
				mkdir($LOGDIR, 0755, true);
				
	define("log",$LOGDIR."/ProxyCreate.log");
	define("err",$LOGDIR."/ProxyCreate.err");
	
	if (file_exists(log)) unlink(log);
	if (file_exists(err)) unlink(err);

	define('RemoteData',  getenv("DDBASE")."/../INFO");
	
	if (!file_exists(RemoteData."/Bases.xml"))
			exit('No Bases.xml'.PHP_EOL);

	$basesDom = new DomDocument("1.0");
 	if (!$basesDom->load(RemoteData."/Bases.xml"))
			exit('Cannot load Bases.xml'.PHP_EOL);

	$bases = $basesDom->getElementsByTagName("dataCenter");
	if ($bases->length == 0)
			exit('No Bases'.PHP_EOL);
	
//	$bases = array("CDAWEB");
	$useSpase = true; 
	
	foreach ($bases as $base)
	{
		// isSimulation -> proxy is being made at AMDA
		if ($base->hasAttribute("isSimulation"))
				continue;
		$class = $base->getAttribute('xml:id');
		echo PHP_EOL.$class.PHP_EOL;
		$center = new $class();
//  			if ($center->monitor())
//  			{
				$center->initProxy();
				$center->makeProxy();
				$center->saveProxy();
//			}
// 			else 
// 			{
// 				print_r("Attention : $class service is down");
 //			}
	}
	
?>